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
- I can't get the props.match.params.id. It's said props is undefined
- How can I use MUI pagination?
- modify specific redux-form value from custom function callback in react-admin
- How to make responsive my react component
- React Component without Function or Class?
- Define non-arrow React functional component for TypeScript?
- Push checkbox values into session storage
- ReactJS: Unable to map through array of objects
- What am I doing wrong with setting up i18next in React? Getting a "i18next::translator: missingKey" error
- Best way to call function again in React
- How to make react-datepicker start the days of the week on Monday?
- Simple selector and nested selector in JSS
- Can I trust react-devtools not to breach my privacy?
- React throwing Error: Objects are not valid as a React child
- TypeError: Cannot read property 'title' and map of undefined React Hooks props problem
- antd design select placeholder issues
- React Router <redirect> not working
- defaultValue of showTime attribute in antd datePicker couldn't set the time
- redux-saga-test-plan put effects do not match, but payload of actual and expected are equal
- how to convert each element in list to separate dictionary react js
- Uncaught TypeError: Cannot read property 'Active' of undefined
- How does one type @connect correctly when using React and TypeScript?
- In react.js, updated state values aren't showing in table list( table list use state value )
- Date object passed as prop becomes [object Object] instead of [object Date]
- Setting up a background image in react JS
- Simple react error mapping through an array twice
- How can I save application state to cookies
- ReactJS - children on specific place
- What is the reason for passing props to super() in a React constructor when props aren't accessed within it?
- Handling sorted and filtered collections coming from APIs in a redux store