How can we pass parameter with this.props.history.push(\'/page\') in React-Router v4?
.then(response => {
var r = this;
if (re
For the earlier versions:
history.push('/path', yourData);
And get the data in the related component just like below:
this.props.location.state // it is equal to yourData
For the newer versions the above way works well but there is a new way:
history.push({
pathname: '/path',
customNameData: yourData,
});
And get the data in the related component just like below:
this.props.location.customNameData // it is equal to yourData
Hint: the state key name was used in the earlier versions and for newer versions, you can use your custom name to pass data and using state name is not essential.