Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access component instance in onRight/onLeft #3274

Closed
thedjinn opened this issue Sep 18, 2018 · 1 comment
Closed

Unable to access component instance in onRight/onLeft #3274

thedjinn opened this issue Sep 18, 2018 · 1 comment

Comments

@thedjinn
Copy link

Version

  • react-native-router-flux v4.0.1
  • react v16.5.1
  • react-native v0.57.0

Problem

I have a scene inside a stack and want to attach some behaviour to the right nav bar button. The router looks roughly like this (irrelevant scenes removed):

<Router>
    <Stack>
        <Scene key="myScreen" component={MyScreen} title="My Screen" rightTitle="Add" />
    </Stack>
</Router>

Now, the problem is that I want to call some method on the component instance. One thing I can do is add the onRight prop to the Scene, but this does not give me access to the component instance, only the component class. Another approach is to add a static onRight() to the component, but once again, no access to the component instance.

Is this functionality currently missing or not working properly? Or am I missing something myself? The documentation and examples are not very clear on how to properly implement this pattern. Thanks for any assistance!

@aksonov
Copy link
Owner

aksonov commented Sep 24, 2018

You can use Actions.refs.SCENE_KEY to access component ref.

@aksonov aksonov closed this as completed Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants