I'm using Navbar as the root file and I have 3 pages(profile, About, and Home), I want to get data from pages to the root file, e.g. (title = "Profile"), because I want to display the title in the navbar.
my navbar page is listed below
import React from "react";
function app(){
return(
<div className="topnav">
<a
style={{
fontWeight: "bold",
fontSize: "20px",
position: "absolute",
margin: "10px",
color: "#001b2b",
}}
>
{title}
</a>
<Link exact to="/profile">profile</Link>
<Link exact to="/home">Home</Link>
<Link exact to="/about">About</Link>
</div>
)}
if I click profile I want to set the title="profile"
I stuck to get data from child component