Search code examples
reactjstypescriptantdant-design-pro

AntD Table navigate to other route on click


I am using React Router in the navigation component but i want to navigate to screen X from screen Y when the user clicks on a table element. Before using antD i did this by using this however does not work here.

    return {
      onClick: event => {
              
      },
   };
}

Solution

  • You can use the react-routers useHistory hook

    const history = useHistory()
    //...
    // somewhere else in the code
    onClick={() => history.push("/route")}