Giter Site home page Giter Site logo

Comments (6)

slorber avatar slorber commented on September 27, 2024 1

The link is old. Yes there's a problem, I'll solve it as soon as I can.

Need to have a proper dev setup first (if you want to help => #28)

from hooks.

cmmartin avatar cmmartin commented on September 27, 2024

I get an infinite loop if I pass navigate as a dependency to useEffect since the function changes on every render

function ReactComponent() {
  const {navigate} = useNavigation();

  useEffect(() => {
      if (user) {
          navigate(...)
      }
  }, [user, navigate])

 return null
}

Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.

My solution, for now, is to not pass navigate as a dependency, but the hooks eslint rule complains and it seems less than ideal. I'm assuming the caching you describe would solve this?

The link you posted is broken FYI

from hooks.

slorber avatar slorber commented on September 27, 2024

Oh, actually navigate() comes from the ReactNavigation context, so it should rather be cached in core

from hooks.

slorber avatar slorber commented on September 27, 2024

@cmmartin the original issue is not totally related to your problem. I've opened a new issue in core for that: https://github.com/react-navigation/core/issues/71

The original issue will be fixed by #3

from hooks.

slorber avatar slorber commented on September 27, 2024

should be fixed by release 1.0.3 and #38, please tell me if everything works

from hooks.

slorber avatar slorber commented on September 27, 2024

@cmmartin ,relative to this issue: https://github.com/react-navigation/core/issues/71

Can you help us understand what you are trying to achieve exactly with the following code?

function ReactComponent() {
  const {navigate} = useNavigation();

  useEffect(() => {
      if (user) {
          navigate(...)
      }
  }, [user, navigate])

 return null
}

Is it something related to switching from authenticated / non authenticated navigators?

from hooks.

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.