Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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>
  );
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #history #push #function #component
ADD COMMENT
Topic
Name
9+4 =