2

After making the changes required by react-router-dom 6, it seems like we no longer receive props from the dom, hence I am no longer able to navigate and pass params this way.

    this.props.history.push({
      pathname: "/search",
      state: sessionStorage.getItem("user"),
    });

I read that an alternative to that was to use useNavigate and it was possible to wrap a class component inside a function and export it as such:

// Wrap and export
export default function (props) {
  const navigation = useNavigate();
  return <login {...props} navigation={navigation} />;
}

This seems too hacky and did not work. anyone is using navigation with passing parameters in Dom v6? how is it done?

Thank you

Yujin Dong
  • 483
  • 2
  • 12

0 Answers0