Answers for "import createHistory from 'history/createBrowserHistory'; const history = createHistory(); useHistory"

9

usehistory example

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

function Home() {
  const history = useHistory();
  return <button onClick={() => history.push('/profile')}>Profile</button>;
}
Posted by: Guest on May-04-2020
0

require("history").createBrowserHistory` instead of `require("history/createBrowserHistory")`

// history.js

import { createBrowserHistory } from "history";
export default createBrowserHistory();
Posted by: Guest on August-25-2020

Code answers related to "import createHistory from 'history/createBrowserHistory'; const history = createHistory(); useHistory"

Code answers related to "Javascript"

Browse Popular Code Answers by Language