score:2
Accepted answer
Looks like this is a bug: https://github.com/ReactTraining/react-router/issues/6072, and possibly even a React bug: https://github.com/facebook/react/issues/12551.
For now, you can get around it by rendering Router
and your context provider in separate components. Like this, for example:
const Routes = () => (
<UserContext.Provider value={false}>
<div>
<ProtectedRoute path='/protected' component={Protected}/>
<Route path='/login' component={Login}/>
</div>
</UserContext.Provider>
);
export default class App extends Component {
render() {
return (
<Router>
<Routes/>
</Router>
);
}
}
Source: stackoverflow.com
Related Query
- React router dom redirect problem. Changes url, does not render component
- React Router does not render Component
- React router dom changes url, does not render component
- React Router Redirect does not render the component
- React Router Dom & Firebase Auth: history.push changes url but does not render new component when called after firebase auth create account
- React Router DOM - Redirect component does not render route properly
- React Router changes route but does not render the component
- React SVG import as a Component does not render
- React Router this.context.router.push does not remount the component
- React Router useHistory. History.push changes url but does not load component
- React Router switch does not mount same component for different routes
- React URL changes but component does not render
- React Router "Link to" does not load new data when called from inside the same component
- React Router does not update component if url parameter changes
- React Router with different paths on same component: does not re-initialize component (useEffect [] not called)
- React router dom passing data from parent component to child router component does not pass the props.match
- Why does react component do not re render after changing state
- React Router will not render Route component unless page is refreshed
- React router does not render route when URL accessed directly
- React router - page does not render until I do a browser refresh
- React Redirect with props does not render final component
- React Router Switch statement with routes grouped as component inside does not go to Not Found route
- React router does not reload component if same element is used for two paths
- React component does not render with curly brackets
- React router Redirect does not work when route comes from another component
- My react onClick navigate shows URL, but does not render component
- React component does not render
- Reactjs - changing url using react router but the component does not change
- React - wrapped component does not render
- NotFound component does not render in Router
More Query from same tag
- How to convert a Laravel project, to a laravel api?
- Django/React - Cookies Stored Under Wrong Domain Name
- Make a MUI v4 Grid element appear with CSS transition?
- React Router 5 - How to define the route for specific page without header and side navigation bar
- firebase.analytics is not a function
- Showing 1 of 2 components on button click
- React js, Maximum update depth exceeded
- Table is not showing data accordingly in Reactjs
- How the get refs antd componement Select value of antd?
- Import web3 not found... in solana web3.js
- How to keep cursor position in a react input element
- How to iterate over HTML content in ReactJS
- how to correctly get (axios) by UUID , ReactJs NodeJs
- react server side validation
- Is it possible to share states between components using the useState() hook in React?
- React DVA JS Framework: Reset entire state application
- File uploader isn't showing the picture
- Load Script only once in Next.js using React hooks?
- How to implement a redux middleware class in TypeScript
- Converting JavaScript Array To JSON Format:JavaScript
- How to always show 2 decimal points after dot in reactjs
- Map state to props not updating after Redux
- Expected an assignment or function call error using the componentdidmount function
- Is there a way in react to find out if an image resource fails to load?
- how can we select multi select from drop down in antd
- Remove the arrow and cross that appears for TextField type=“time” material-ui React
- vanilla bootstrap in react tooltip issue
- Solve Jest test error from Webpack plugin
- How to install SSL for the following setup (React Frontend + Nodejs Backend + Custom Domain Heroku)
- React Create simple form