rn-tourguide icon indicating copy to clipboard operation
rn-tourguide copied to clipboard

Start method is not working inside useEffect .

Open ForamPattha opened this issue 3 years ago • 5 comments

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 .

ForamPattha avatar Apr 08 '21 06:04 ForamPattha

Same issue, canStart is always false and never changed. But startAtMount works properly!

moh3n9595 avatar May 25 '21 14:05 moh3n9595

Solution: TourGuideProvider and start() should not be at the same level!

moh3n9595 avatar May 25 '21 15:05 moh3n9595

try

useEffect(() => {
   if(canStart) {
        start && start();
   }
},[canStart])

farhan-ibrahim avatar Jun 04 '21 08:06 farhan-ibrahim

This seems to work on the latest version. The example app does the same.

bucketclan avatar Feb 06 '22 03:02 bucketclan

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.

anniewey avatar Mar 07 '23 02:03 anniewey