What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-23 01:56:53
handling scrolling on react router transitions
import { useEffect } from 'react'; import { withRouter } from 'react-router-dom'; function ScrollToTop({ history }) { useEffect(() => { const unlisten = history.listen(() => { window.scrollTo(0, 0); }); return () => { u... Add solution -
Javascript 2021-12-23 19:26:21
@types react-router-dom
npm install --save @types/react-router-dom Add solution -
Javascript 2021-12-23 17:45:09
import withrouter
import { withRouter } from 'react-router-dom'; Add solution -
Javascript 2021-11-21 11:56:38
how to redirect react router from the app components
import React from 'react' import { Redirect } from 'react-router-dom' const ProtectedComponent = () => { if (authFails) return <Redirect to='/login' /> } return <div> My Protected Component </div> } Add solution -
-