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

Tabs mounting all components on start #2034

Closed
isAlmogK opened this issue Jul 14, 2017 · 4 comments
Closed

Tabs mounting all components on start #2034

isAlmogK opened this issue Jul 14, 2017 · 4 comments

Comments

@isAlmogK
Copy link

So I don't think this is a bug but I'm not sure this is correct behavior also this might be caused be React Navigation.

If you have a tabs component on app start once tabs are loaded it also loads all the view components for each tab.

So if you have the following

<Scene key="tabBar" tabs>
 <Scene key="tab1" title="Home" tabBarLabel="Home" icon={HomeTabIcon}>
  <Scene key='Home' component={Home} title='Home' initial={true}  panHandlers={null}/>
     <Scene key='Teams' component={Teams} title='Teams' initial={false} />
   </Scene>
  <Scene key="tab2" title="Photos" tabBarLabel="Photos" icon={PhotosTabIcon}>
<Scene key='Photos' component={Photos} title='Photos' initial={false} />
</Scene>
<Scene key="tab3" title="Site Diary" tabBarLabel="Site Diary" icon={SiteDiaryTabIcon}>
<Scene key='SiteDiary' component={SiteDiary} title='SiteDiary' initial={false} />
</Scene>
</Scene>

As soon as home loads it also loads photos and site diary.

For the most part, this is fine but if you need to make API calls in componentDidMount you really can't. This feels like the wrong way with react, I thought the whole idea is to make API calls inside componentDidMount once the component is mounted or navigated to.

@aksonov
Copy link
Owner

aksonov commented Jul 14, 2017 via email

@isAlmogK
Copy link
Author

No, I have not how do I set that? or is there an example or docs?

@aksonov
Copy link
Owner

aksonov commented Jul 14, 2017

Sorry, docs are not ready (PR is welcome). As I said before all tabs/stack configs are passed directly to StackNavigation/TabNavigator. So you can check 'lazy' attribute within TabNavigator docs.

@isAlmogK
Copy link
Author

Thanks lazy does it

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