Answers for "redirect to new page in react on buttn click using redirect tag"

2

react 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 February-08-2021

Code answers related to "redirect to new page in react on buttn click using redirect tag"

Code answers related to "Javascript"

Browse Popular Code Answers by Language