score:0
try it:
<menu>
<lint to="/">
<menubutton>
home
</menubutton>
</lint >
</menu>
<menu>
<link to="/about">
<menubutton>
about us
</menubutton>
</link >
</menu>
if your livestock router version is 6, you should do this:
import {
browserrouter,
routes,
route,
} from "react-router-dom";
<browserrouter>
<routes>
<route path="/" element={<home/>}>
<route path="/about" element={<aboutus/>}>
</route>
</route>
</routes>
</browserrouter>
score:0
try using the <link />
component on the <navbar />
component instead of <a>
tags.
thus your code should look like
<menu>
<link to="/home">
<menubutton>
home
</menubutton>
</link>
</menu>
<menu>
<link to="/about">
<menubutton>
about us
</menubutton>
</link>
</menu>
for more info about the <link />
component you can read through the react-router docs.
Source: stackoverflow.com
Related Query
- React router is taking me to the same page
- React Router - Stay at the same page after refresh
- React router is not reloading page when url matches the same route
- React Router Issue: React render two components in the same page
- React Router renders the target page on the same page
- React router how to display each component on click on the same page
- React Router V4 - Warning: You tried to redirect to the same route you're currently on: "/home/dashboard"
- activeClassName in react router is highlighting two NavLinks at the same time
- Reload the page gets 404 error using React Router
- react router Link doesn't cause rerender when visited on the same path
- React Router V4: How to render a modal in the same screen changing only the url and then with that url, be able to rebuild the whole screen
- React router v4 history.push to the same route (different query params) in Functional Component (use Hooks API)
- Is there a clean way to conditionally load and render different components for the same React Router route?
- React Router - Go back to the last page visited, and not the default component
- React router - pass api data to the linked component to open with a new page
- React : How to stop re-rendering component or making an API calls on router change for the same route
- React Redux with redux-observable use the router to navigate to a different page after async action complete
- React router gives "redirect to the same route" error
- React Router v5: history.push() changes the address bar, but does not change the page
- How to display the state on the same page when clicked Submit button in react
- React Router List and Detail Route at the same time
- how to update a route in React Router without re-mounting the component in a single page app?
- React Router doesn't load the new page component after redirecting via navigate
- Using the same component for different Routes with React Router
- React Router scroll page to the top after transition
- React router render component on same page
- React router redirects the page but component doesn't get rendered
- React Router v4: Component and Children in the same route
- React Router's v6 history.push('/') giving error of "undefined (reading 'pathname')" - url changes, but page stays the same
- React router returning the same element
More Query from same tag
- Pass a state value from child to parent component in react in componentwilmount
- How to pass data from API using useContext?
- undefiined useContext destructure
- React. how to pass props from onClick to function
- How to clear events listeners in react after removing an element from the DOM
- Reactjs, search filter does not work correctly, when i load more users
- useSelector updating even if value hasn't changed
- How to control react-bootstrap carousel with custom buttons?
- state destructuring trouble in redux
- Using react refs and forms
- Don't pass value to component if string equals "" empty
- Remove items dynamically from table/list
- Is it possible to restrict to multiple roles in react-admin?
- Can't get the updated value in the context provider
- Share function with React Router to all routs
- First dynamically added component not getting styling from a class
- React: Create CSV at client side with data retrieved from backend via Socket IO
- Tailwind dark mode toggle works but styles do not change
- Prevent class .cke_show_borders to be added to table element in ckeditor
- Too many re-renders when using custom hook
- Using Order property in React-Responsive UI
- React setState not merging all changes
- Why Tooltip from primereact library doesn't work to tag <pre>?
- Making an HTML string from a React component in background, how to use the string by dangerouslySetInnerHTML in another React component
- React Javascript - setState issue and copyToClipboard issue with scaleable button+p render
- Run function after setting state with hooks
- React Apollo client prop refetchQueries after mutation
- Ionic React Typescript with pug.js, 'Uncaught ReferenceError: React is not defined' when use tsx but not jsx
- How to return jsx after setTimeout
- Preventing "not wrapped in act(...)" Jest warning when state update doesn't affect UI