Coder Social home page Coder Social logo

Comments (7)

plus- avatar plus- commented on May 2, 2024

Is this pattern solved with v5.0? I'd like to use it but the emit function doesn't seem to be exposed in the useNavigation hook

from rfcs.

satya164 avatar satya164 commented on May 2, 2024

You can use setOptions to directly access screen's state and props in your header. An event emitter is not needed.

https://reactnavigation.org/docs/en/navigation-prop.html#setoptions---update-screen-options-from-the-component

from rfcs.

plus- avatar plus- commented on May 2, 2024

Right,

What about function calls should I pass the function in the options or use a forward ref on the screen?

from rfcs.

satya164 avatar satya164 commented on May 2, 2024

Not sure what you mean. There's an example here https://reactnavigation.org/docs/en/headers.html#updating-options-with-setoptions

from rfcs.

plus- avatar plus- commented on May 2, 2024

Say you have a screen with a form component, and the submit button is in the navigation header.

I don't want to pass the form content nor the submit function in the navigation params. My first though was to emit a submit event and listen it from the form, but it's not possible in v5 (no emit function available).

My current solution (not sure if it's the best) is to do a forward ref on the form component so the button can access the submit function (exposed with useImperativeHandle).

Is there a better pattern with v5 to handle this situation?

from rfcs.

satya164 avatar satya164 commented on May 2, 2024

Have you actually checked the links I shared?

from rfcs.

plus- avatar plus- commented on May 2, 2024

Yes, but it was still not clear to me. This other link though is pretty straightforward: https://reactnavigation.org/docs/en/header-buttons.html#header-interaction-with-its-screen-component

cheers

from rfcs.

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.