I want to redirect the user to a URL when the user clicks on a button. This code already works:
render(): React.ReactNode {
if (this.state.redirect)
return <Navigate to="/adduser" />;
//...
}
Now I need to pass data to the component and apparently this is the way:
<Navigate to="/adduser" state={{ user: this.state.users[selectedUserIndex] }} />
But I don't know how to access the passed data inside the component. All of my code is based on class components. How can I access this data from class component?
Thank you