Answers for "How to use history push within function component with parameters?"

4

react router history push parameter

this.props.history.push({
  pathname: '/template',
  search: '?query=abc',
  state: { detail: response.data }
})
Posted by: Guest on March-17-2020
0

How to use history push within function component with parameters?

function Button({ path, text }) {
  const history = useHistory();
  function handle(){
    history.push(path); // This should work now
  }
  return(
    <button onClick={handle}>
      {text} // This should render now
    </button>
  );
}
Posted by: Guest on September-17-2021
0

How to use history push within function component with parameters?

function Button({ path, text }) {
  const history = useHistory();
  function handle(){
    history.push(path); // This should work now
  }
  return(
    <button onClick={handle}>
      {text} // This should render now
    </button>
  );
}
Posted by: Guest on September-17-2021

Code answers related to "How to use history push within function component with parameters?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language