Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created February 19, 2020 17:08
Show Gist options
  • Save sibelius/7d760fa16a121ec0f4cd8b143a59bee6 to your computer and use it in GitHub Desktop.
Save sibelius/7d760fa16a121ec0f4cd8b143a59bee6 to your computer and use it in GitHub Desktop.
withRouter for react-router-dom v6
import { useHistory } from 'react-router-dom';
export const withRouter = (Component) => {
const Wrapper = (props) => {
const history = useHistory();
return (
<Component
history={history}
{...props}
/>
);
};
return Wrapper;
};
Copy link

ghost commented Jun 14, 2022

useNavigate working perfectly...

Okay Bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment