I'm attempting to pass a function to be used as a callback in a different route. I know it's possible to do this:
import { useHistory } from "react-router-dom";
const FirstPage = props => {
let history = useHistory();
const someEventHandler = event => {
history.push({
pathname: '/secondpage',
state: { detail: 'some_value' }
});
};
};
but I get this error when I try pass a callback function like this:
my code with callback:
const someEventHandler = event => {
history.push({
pathname: '/secondpage',
state: { my_callback: selectedPlaylist }
});
};
error:
DataCloneError: Failed to execute 'pushState' on 'History': selectedPlaylist => {
....
}
Is this just something that cannot be done since it's a reference to a function and not necessarily state? Is there a workaround? I'm not able to find any resources similar to this. Thanks in advance!