Answers for "how to rediret to a react-router path on click"

1

react-router-dom redirect on click

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

function app() {
  let history = useHistory();

  const redirect = () => {
    history.push('/your-path')
  }

  return (
    <div>
      <button onClick={redirect}>Redirect</button>
    </div>
  )
}
Posted by: Guest on December-10-2020

Code answers related to "how to rediret to a react-router path on click"

Code answers related to "Javascript"

Browse Popular Code Answers by Language