We want to show the NavBar section and the home ( doc) page first when the screw is loaded.
- The NavBar section should be fixed at the top of the page along the entire site.
- The Header section (or home) should be displayed at the beginning of the screen load. Given that these two parts must be indexed at the top of the page at the same time, the header And we made NavBar the father of all links that is fixed at the top of the page
Problem: The problem is that the NavBar page is loaded, but other pages that are clicked on are not loaded and updated in the body by clicking on them, and also the Header document that is index is not loaded.
//index and make router:
export default function App() { return ( <BrowserRouter> <Routes> <Route path="/" element={ <NavBar home_text={"Home"} contact_text={"Contact"} opinion={"Opinion"} /> }> <Route index element={<Header />} /> <Route path="contact" element={<Contact />} /> <Route path="opinion" element={<Opinion />} /> </Route> </Routes> </BrowserRouter> ); }
//NavBar document
function NavBar(props) { console.log(props) return ( <> {props.home_text}
<li className="menu_item dc"> <Link to="/contact"><span className="style_of_text ">{props.contact_text}</span> </Link> </li> <li className="menu_item dc"> <Link to="/opinion"><span className="style_of_text ">{props.opinion}</span> </Link> </li> </ul> </div> </> ); }