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

Better way to declare rightTitle/onRight inside component #2244

Closed
danieljvdm opened this issue Aug 15, 2017 · 3 comments
Closed

Better way to declare rightTitle/onRight inside component #2244

danieljvdm opened this issue Aug 15, 2017 · 3 comments

Comments

@danieljvdm
Copy link

I'm currently following the example in Login.js and doing the following:

componentDidMount() {
    Actions.refresh({
      rightTitle: 'rightTitle',
      onRight: () => {
        this.searchDropdown.toggle();
      },
    });
}

However, this causes a rerender and also resets my refs.

<SearchDropdown ref={this.searchDropdown} />

This ref exists on the first render but is set to null on the second render (caused by Actions.refresh). Is there a better way to set up the navbar before the component is rendered?

@aksonov
Copy link
Owner

aksonov commented Aug 16, 2017

It is wrong approach - declare rightTitle and onRight as static function for your component. You could access to your component ref via Actions.refs.SCENE_NAME #2195

@aksonov aksonov closed this as completed Aug 16, 2017
@danieljvdm
Copy link
Author

Ok, it would be useful if you also mentioned that this was a mistake in the example, not my mistake.

e8c5a42#diff-32afed19f718c82f2588a4adaa45100e

@aksonov
Copy link
Owner

aksonov commented Aug 16, 2017 via email

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