Why `Failed to execute 'pushState' on 'History'` when using `Link` from react-router-dom?
Firstly, add some default value to your addExpense
function:
addExpense = (expense = DEFAULT) => {
console.log('Hello From addExpense');
}
Then Use Link
:
<Link to={`/ideas/${this.addExpense}`}>Create Expense</Link>
OR Try this (Better Approach):
goToNextPage = (addExpense) => {
this.props.history.push({
pathname: '/create',
state: { addExpense: addExpense }
});
}
In next (create
) component use the passed on values like this:
this.props.location.state.addExpense();