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

Maximum update depth exceeded #73

Open SikoraKam opened 2 years ago

SikoraKam commented 2 years ago

I use react-native-navigation so I have to keep multiple Providers, one for each screen with tour. So far I implemented tour for two screens and everything was fine. But on third screen, using useTourGuideController() causes error "Maximum update depth exceeded...". When I tried to debug I saw that functions stop and start cause rerenders. Did anybody has similar problem?

mcanikhilprajapati commented 2 years ago

same i am facing

mcanikhilprajapati commented 2 years ago

try to add context on top of all function

sarath40158 commented 2 years ago

@mcanikhilprajapati can you provide some code for this ?

HaiyangZhang1994 commented 2 years ago

try to add context on top of all function

Have same problem, could you please share more info?

sarath40158 commented 1 year ago

Any one having same issue 👍 I have fixed this by moving from top level to Other Entry File of the App flow

Just try by changing from top level to to wrapping up to any of entry file Like

alphacodedev99 commented 1 year ago

Hello i have same problem, pls if someone can help me, add on Discord: Alpha Tica#7499, and help me to fix my app, i have short deadline.. tnx in advance

surbhitrao commented 1 year ago

I was also having the same issue. I had to use TourGuideZoneByPosition in place of TourGuideZone. I'd recommend using Dimensions to find the exact position of the tour overlay.

Use the TourGuideZoneByPosition after importing like this

const { canStart, start, stop, eventEmitter, TourGuideZoneByPosition, tourKey, } = useTourGuideController();

And not import { TourGuideZoneByPosition, useTourGuideController, } from 'rn-tourguide';

renatomserra commented 1 year ago

Having the same issue trying to set a guided tour on an element in a TopNavigator element, the lib was working so perfectly everywhere else :( Even with TourGuideZoneByPosition it fails as soon as i add the prop isTourGuide with the same error

pke commented 1 year ago

Thats because start exported from the hook is unstable. Its changing after every render. When eslint complains that it needs to be part of the useEffect dependency array, just ignore this warning. The dependency array must only contain canStart like the example code shows. It started to work flawlessly then.

  // this works
 React.useEffect(() => {
    canStart && start()
  }, [canStart])

  // This makes eslint happy but causes infinite render loops
 React.useEffect(() => {
    canstart && start()
  }, [canStart, start])

I am still suspicious of libs that don't export stable functions from their hooks what other re-render problems they may cause. @xcarpentier any idea why the function is not stable?

tcagkansokmen commented 5 months ago

facing the same issue. none of the comments above could solve my issue. any suggestions?