In my react function, I could write:
const history = props.history;
or
const history = useHistory();
Then I can use history.push()
or history.goBack()
in the same way.
So I wonder if they are different or not?
In my react function, I could write:
const history = props.history;
or
const history = useHistory();
Then I can use history.push()
or history.goBack()
in the same way.
So I wonder if they are different or not?
Few Differences in this two
conclusion : if you are using class component then use props.history and if you are using functional component then use useHistory() hook
© 2022 - 2024 — McMap. All rights reserved.
useHistory()
in any component, butprops.history
only in components where thehistory
is available in props. – Quesnay