Answers for "usehistory push"

8

useHistory

import { useNavigate } from 'react-router-dom';
const navigate = useNavigate();
navigate('/home');
Posted by: Guest on December-02-2021
0

history.push.hook

import { useHistory } from "react-router-dom";

export const usePushHistory = () => {
  const history = useHistory();

  const onChangePage = (value) => {
    history.push({ pathname: value });
  };

  return {
    onChangePage,
  };
};
Posted by: Guest on March-08-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language