Answers for "how to pass function props in history.push react router"

6

passing data in react router history,push

this.props.history.push({
  pathname: '/template',
  search: '?query=abc',
  state: { detail: response.data }
})
Posted by: Guest on February-05-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 pass function props in history.push react router"

Code answers related to "Javascript"

Browse Popular Code Answers by Language