Advertisements
I want to call a function on the second screen as soon as the screen navigates to the second screen. Is it possible?
This is related to firebase phone auth but here the OTP screen is on another screen not on the same screen.
>Solution :
on the screen, you can use useEffect
to call a function on load or when a prop changes.
e.g. if you just want to load it once when page renders:
const getMyStuffFromTheApi = () => {
//TODO
}
React.useEffect(() => {
getMyStuffFromTheApi();
}, []);
e.g.2 if you want to call the function every time the prop changes
const getMyStuffFromTheApi = () => {
//TODO
}
React.useEffect(() => {
getMyStuffFromTheApi();
}, [yourProp]);