xcarpentier / rn-tourguide

🚩Make an interactive step by step tour guide for your react-native app (a rewrite of react-native-copilot)
https://xcarpentier.github.io/rn-tourguide/
Other
725 stars 213 forks source link

Start method is not working inside useEffect . #47

Open ForamPattha opened 3 years ago

ForamPattha commented 3 years ago

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 .

moh3n9595 commented 3 years ago

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

moh3n9595 commented 3 years ago

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

farhan-ibrahim commented 3 years ago

try

useEffect(() => {
   if(canStart) {
        start && start();
   }
},[canStart])
bucketclan commented 2 years ago

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

anniewey commented 1 year ago

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.