rn-tourguide
rn-tourguide copied to clipboard
Start method is not working inside useEffect .
I want to call tourguide after api calling is completed in dashboard . so I called start() inside my function . but it return with error : TypeError: start is not a function. (In 'start()', 'start' is undefined) . I'm using react native with typescript. Also When first time screen loaded mask position is not set for 1st zone . even I just call start() like this is also not working : useEffect(() => { start?.(1) }, []) but it doesn't work .
Same issue, canStart
is always false and never changed.
But startAtMount
works properly!
Solution:
TourGuideProvider
and start()
should not be at the same level!
try
useEffect(() => {
if(canStart) {
start && start();
}
},[canStart])
This seems to work on the latest version. The example app does the same.
Following the example but getting missing dependency error. While including start
in dependency will cause infinity loops. How to get it work?
useEffect(() => {
if (canStart) {
// 👈 test if you can start otherwise nothing will happen
start();
}
}, [canStart]); //throwing error: React Hook useEffect has a missing dependency: 'start'. Either include it or remove the dependency array.