I'm trying to pass state data after navigating to a new route and typescript is telling me
Property 'email' does not exist on type 'State'."
Parent functional component:
navigate('/check-mail', { state: { email: "hello, I'm an email" } });
Child functional Component:
const SentPasswordResetInstructions = () => {
const location = useLocation();
let { email } = location.state;
}
I've tried creating an interface like so:
interface propState { email : string }
and then using
useLocation<propState>();
However that throws additional errors. How do I fix this ??
Just solved it! Creating the interface:
interface propState {
email: string;
}
And then using
let { email } = location.state as propState;
Worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With