score:1
Accepted answer
Try using Routes instead of switch.
- import Routes
import { BrowserRouter , Redirect, Route , Routes, Switch } from 'react-router-dom';
- Change the Switch to *Routes
<Routes>
<Route exact path="/" >
<Home />
</Route>
<Route path="/details" >
<Details />
</Route>
<Route path="*">
<Redirect to="/" />
</Route>
</Routes>
I hope this helps
score:1
Upgrade to React-router-dom: Version: 5.3.3 because Version: 5.1 has bug.
1.Uninstall whatever version you are having
npm uninstall -s react-router-dom@5.1
npm uninstall -s react-router-dom
2.Install React-router-dom: Version: 5.3.3
npm install -s react-router-dom@5.3.3
Or go to this post: Click Me to go to Post
Source: stackoverflow.com
Related Query
- React URL changes but component does not render
- React Router Dom & Firebase Auth: history.push changes url but does not render new component when called after firebase auth create account
- React Router: Changes URL but does not render component
- React Router useHistory. History.push changes url but does not load component
- history.push changes URL but does not render any component
- history.push changes url but does not render form react hooks
- URL changes but component is not render - React Router
- React Router changes route but does not render the component
- why react router url changes but component does not load in my nested router app
- react-router changes URL but does not render component
- React Link changes URL but does not render page
- React router dom redirect problem. Changes url, does not render component
- React Link tag changes the url but doesnt render the component
- React Router does not update component if url parameter changes
- React router dom changes url, does not render component
- React url changes but render is not working?
- Firebase data changes state but does not render component
- React Router Link changes URL but doesn't render Component - Rest Countries API
- My react onClick navigate shows URL, but does not render component
- Reactjs - changing url using react router but the component does not change
- React-router Link Changes URL ID but Component Does Not Reload
- React router changes url but not the component [SOLVED]
- Importing New React Component Compiles But Does Not Render
- The links do not render the components of ReactJS. The URL changes but the page does not?
- React Router - URL changes but not Component
- React Router url updates but component does not
- URL changes with React Router but component not rendering?
- React router changes the url but not reload the component
- React router url changes correctly but component not being rendered from button component link
- React BrowserRouter Changes URL but Component doesn't Render
More Query from same tag
- How to add onMouseDown listener via HOC
- I want to show a successful warning post after a file uploaded using React js
- In Next.js, how to create a bg image that covers the entire browser window
- passing component & props in function react js
- Does react have a "null element"?
- Othello Game Switching Turns Doesn't Work in React.js
- How can I define the type for a <video> reference in React using Typescript?
- How can I use an empty array declared on React's initial state?
- Right-hand side of 'instanceof' is not callable
- (found: [object Promise]) with Material UI and DexieJS
- Changing Unicode symbols (") to the equivalent html symbol (")
- Pass Dispatch to onClick Event Redux
- React hooks: Update an object value within an array in state
- My component disappeared from my React Application
- Access container props in mapDispatchToProps
- ReactJS with CoffeeScript with Rails ReferenceError: <component> is not defined
- How to invoke a function written in html root script from a react component
- How to set proxy when using axios to send requests?
- Proper way to hide calendar icon (suffix icon) in DatePicker for AntD
- Component rerendering only after double click
- How to yield inside an external callback function in react redux saga?
- Render to another functional component based on route
- Why does sort not work in React component
- How to access the sub object of your array object using useReducer
- Not able to add my provider in side the index.js file in reactjs
- jsx must wrap with an enclosing tag error
- React export to csv - No Headers in the csv file
- React: How do I access a component from another component?
- Django, Create-react-app, Heroku
- React.js reading from a local file