-
-
Save marabesi/06bf6e21ff92a980a3fc155145f36d41 to your computer and use it in GitHub Desktop.
withRouter for react-router-dom v6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useNavigate } from 'react-router-dom'; | |
export const withRouter = Component => { | |
const Wrapper = (props) => { | |
const history = useNavigate(); | |
return ( | |
<Component | |
history={history} | |
{...props} | |
/> | |
); | |
}; | |
return Wrapper; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment