Giter Site home page Giter Site logo

Comments (4)

daihovey avatar daihovey commented on September 27, 2024 1

+1 - have same issue as @lichwa

from hooks.

slorber avatar slorber commented on September 27, 2024

Hi,

According to the code, I don't feel like it's related to hooks but rather related to react navigation core. Can you see if it works better without hooks?

I suspect setting params synchronously just after render makes something weird happen. As it triggers a re-render and we are still mounting the screen, the navigation options might be computed twice, because the screen has to render twice during the render phase.

But why do you want to set a param synchronously in useEffect in the first place, instead of using the navigation options? What's the usecase for this? This will only lead to unnecessary double-render on mount, while setting directly test: true param in navigation options would prevent it.

from hooks.

norbertsongin avatar norbertsongin commented on September 27, 2024

Setting params in componentDidMount was always working fine for me and I thought this was equivalent of setting them in useEffect.

In my case I need to set a param to function that's declared in my screen's scope.

from hooks.

slorber avatar slorber commented on September 27, 2024

If you can share a snack with both componentDidMount and useEffect that would help, currently I don't have much time to help.

https://github.com/react-navigation/hooks/blob/master/src/Hooks.ts#L13
The hook does almost nothing so I don't think the issue is in this project.

navigationOptions undefined
component did mount
navigationOptions {test: true}

Maybe the issue is we shouldn't call navigationOptions twice during mount?

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.