Giter Club home page Giter Club logo

Comments (9)

work4m avatar work4m commented on June 27, 2024 17

I encountered an issue where the code wasn't functioning within the useEffect or useFocusEffect hooks. However, I managed to identify the solution that works perfectly for my use case in the code. To implement this, make sure to place the following code snippet within the top-level container:

<View onLayout={() => start()}>

from react-native-copilot.

lurdharry avatar lurdharry commented on June 27, 2024 3

I had similar issue but was able to fix it, Here is my solution

const { currentStepNumber } = useCopilot()
  const isMounted = useIsMounted();
  
useEffect(() => {
    const timeout = setTimeout(() => {
      if (isMounted.current && currentStepNumber === 0) {
        start();
      }
    }, TIMEOUT);
    return () => clearTimeout(timeout);
  }, [currentStepNumber, isMounted,  start]);
  

you can search for IsMounted Hook, but I can help you with it if you are unable to find any.

from react-native-copilot.

Saigronas avatar Saigronas commented on June 27, 2024

The fix @lurdharry mentions does not work here.

Any update would be greatly appreciated.

from react-native-copilot.

lurdharry avatar lurdharry commented on June 27, 2024

@Saigronas try replacing the useEffect hook with useFocusEffect hook from react navigation.

It was working well when I used useEffect but it stopped working at some point may be due to metro bundler cache issue, but since I changed to useFocusEffect , it has been working perfectly even in production.
And also, you don’t need the userIsMounted hook when using useFocusEffect.

from react-native-copilot.

Saigronas avatar Saigronas commented on June 27, 2024

Even by using useFocusEffect, (which i already used for another reason), i cannot get the tour to start on its own or by navigating to the screen.

However, when pressing "ctrl+s" and thereby refreshing the app, the tour starts.
This was also the case with using useEffect

from react-native-copilot.

tanmoygo avatar tanmoygo commented on June 27, 2024

@Saigronas did you get any solution?

from react-native-copilot.

shreya-kalra-vs avatar shreya-kalra-vs commented on June 27, 2024

any update on the issue?

from react-native-copilot.

NewDimix avatar NewDimix commented on June 27, 2024

@Saigronas did you get any solution?

from react-native-copilot.

carl0shd avatar carl0shd commented on June 27, 2024

same problem here, the start() doesn't work if it is called inside of a useEffect

from react-native-copilot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.