Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to use usenavigate in react class component

For those who are struggling with route v6 and more. You must define a function outside of your component Class and use it as following:

function myParams(Component) {
    return props => <Component navHook={useNavigate()} />;
}
in your Class component:

this.props.navHook('/SomeWhere')
And keep in mind you have wrap your Class in your function:

export default myParams(Card);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #usenavigate #react #class #component
ADD COMMENT
Topic
Name
1+4 =