score:2
Accepted answer
<switch>
<route exact path="/" component={home} />
<route exact path="/about" component={about} />
<route component={error} />
</switch>
do not add a path for error route.
Source: stackoverflow.com
Related Query
- React Router not found page showing up on all paths
- Page not found is displayed on all my pages - React Router
- How to redirect to not found page if slug doesn't exist using React Router Dom?
- My 404 not found page with React router is not working
- Flask + React + Nginx: pages showing 404 not found for all routes with port number 80
- Show react router v4 not found page
- React router not open 404 not found page
- How can handle not found page for nested routing in react router v4?
- React Router not working in simple app, showing blank page
- React router not showing a page
- React Router URL not found if refresh page - Create React App
- Not found page and default home page always redirect to home - React Router
- useEffect not running at all when navigating to page with React Router
- React Router not showing a page - React JS
- React router not going to not found page
- React Router BrowserRouter leads to "404 Not Found - nginx " error when going to subpage directly without through a home-page click
- React router not showing browser history
- Surge-deployed React app - getting 404 Page Not Found
- react helmet not showing meta tags in view page source but shows in element on inspect
- React Starter Kit error - page not found
- React Native: Android is not showing all images (even though they are the same)
- React Router - Go back to the last page visited, and not the default component
- React router is not reloading page when url matches the same route
- React app showing page with "404 the requested path could not be found" when using Apache
- React Router v5: history.push() changes the address bar, but does not change the page
- React Router - 404 page always showing due to custom route component
- React Router v5 nested routes not found
- React recaptcha google not showing at all
- React Router not showing the component
- React js Router changes url but not loading page
More Query from same tag
- file input files not read onChange on mobile
- Blog using React, GraphQL, GraphCMS, NextJS, Tailwind CSS
- how to hide one div when another div is active in react js
- Detect previous path in react router?
- ReactQuery make refetch with old data
- Return Data From Other Component [React Native/React]
- Action does not trigger reducer
- Scroll to a custom component
- Detect DOM loading completion
- How can I pass auth headers to other components
- React - rotate chevron on click
- Functional Component not receiving props in react
- JSON-LD schema with GatsbyJS for rich snippets
- Problem unit testing a delete method with mock service worker (MSW), node and React
- How to create a wrapper for an Apollo query that uses React hooks
- How to find .babelrc?
- Unable to use hook in HOC for functional component
- ERROR in Entry module not found: Error: Can't resolve './src' in
- React excel file download corrupt
- Want to set state once on first render without causing uneccessary re-renders on further updates
- How to send query in react-router
- Next.js How to make a redirect correctly
- Get attribute value from same element method in React
- Getting div's attribute value in the different function (REACT)
- Redux with Gatsby - wrapped Provider is not recognized
- React - Using ternary to apply CSS class in functional component
- How to combine conditions taking different parts of an object as parameter in react.js for CSS
- After editing only one field is edited and the other one behaves unexpectedly (React hooks)
- Unexpected token when mapping in React
- How should I pass the data in my API link