add the history in top of the code like `import {history} form react-router-dom
history.push({
pathname:"/users",
state:{
Key : response.data.user }
});
See the upgrade guide in the documentation.
Use useNavigate instead of useHistory
let navigate = useNavigate();
const someFunction = () => {
const options = {
state: {
Key: response.data.use
}
}
navigate("/users", options);
}