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

All tab view of tabs are mounted once. #2197

Closed
lazyhoneyant opened this issue Aug 7, 2017 · 4 comments
Closed

All tab view of tabs are mounted once. #2197

lazyhoneyant opened this issue Aug 7, 2017 · 4 comments

Comments

@lazyhoneyant
Copy link

lazyhoneyant commented Aug 7, 2017

Version

Tell us which versions you are using:

  • react-native-router-flux 4.0.0-beta.16
  • react-native 0.45.1

I have tabbar which have 4 tabs.

When I enter the first tab of tabbar, other tabs are mounted ( checked this in componentDidMount life cycle function)

Additionally, When I pressed another tab, old tab view component was not unmounted.

Is it normal behavior?

This makes App to call unnecessary API calls.

@giulianok
Copy link

Same here

I had to move the <Scene> to the tab component, return it inside of a function and call it where I need the scene. Then, I used onEnter instead of componentWillMount or componentDidMount.

I can show you the code if you need it

Besides, we should have the option to not mount the components until we enter

@lazyhoneyant
Copy link
Author

@giulianok
I want to see your codes.
You mean that to work around this bug(?) you use 'onEnter' method. right?
I think so that we need to option to not mount the components until we actually enter.
When a tab is switched to another scene, previous tab component needs to be unmounted too.

@aksonov
Copy link
Owner

aksonov commented Aug 8, 2017

@lazyhoneyant Use lazy option. Will add it to docs. Component will NOT be unmounted after switching - it is how tabbar works.

@lazyhoneyant
Copy link
Author

lazyhoneyant commented Aug 8, 2017

@aksonov
thank you. lazy option solves this problem.

@aksonov aksonov closed this as completed Aug 8, 2017
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

3 participants