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

Using onEnter/onExit from Component #2081

Closed
luco opened this issue Jul 20, 2017 · 9 comments
Closed

Using onEnter/onExit from Component #2081

luco opened this issue Jul 20, 2017 · 9 comments

Comments

@luco
Copy link
Contributor

luco commented Jul 20, 2017

Is there a way from using onEnter and onExit from component itself?
I mean, I want to call a function from my component every time I enter on it.

I tried using on Scene component, but wasn't lucky.

@woodpav
Copy link

woodpav commented Jul 20, 2017

I wanted to do something similar. Calling Actions.refresh() in the transitioning scene rerenders the new scene so you could put something in componentWillReceiveProps

@aksonov
Copy link
Owner

aksonov commented Jul 21, 2017

@luco Have you tried to add onEnter/onExit on containers or on child? It works only for child. I've just added possibility to define them on component level (as static functions), please check.

@rochapablo
Copy link

Shouldn't this be working?

<Scene key="login" component={Login} title="Login" onEnter={this.doSomething} />

@aksonov
Copy link
Owner

aksonov commented Jul 21, 2017

Depends from what is this.doSomething. Just put onEnter={()=>console.log("onEnter!")} to see log

@rochapablo
Copy link

Yep, you're right! I may be doing something wrong. Thank you.

@EnriqueDev
Copy link

I still don't really understand how onEnter works. Is it possible to call a function from the component from there? Is there a tutorial / doc on how to use it?

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

Demo is in progress... You may define it as static component function

@ghost
Copy link

ghost commented Sep 25, 2018

Is there such event listener for Drawer? I need to listen for Drawer opens/closes. I can't find this in docs.

@daviscabral
Copy link
Collaborator

daviscabral commented Sep 25, 2018

<Drawer /> is the same as <Scene drawer />. When it opens/closes is the onEnter/onExit event - but you can also use only react-navigation for that with NavigationEvents.
https://github.com/aksonov/react-native-router-flux/blame/master/docs/API.md#L67

EDIT: This event is available for Drawer only react-native-router-flux@^4.0.2 - previous versions does not support it.

EDIT2: Check out the examples folder - I believe there are something there showing it.

Repository owner locked as resolved and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants