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

Lazy property doesn't work on tab #2296

Closed
ValentinBlokhin opened this issue Aug 28, 2017 · 11 comments
Closed

Lazy property doesn't work on tab #2296

ValentinBlokhin opened this issue Aug 28, 2017 · 11 comments

Comments

@ValentinBlokhin
Copy link

ValentinBlokhin commented Aug 28, 2017

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.21 (v3 is not supported)
  • react-native v0.47.2

Expected behaviour

Tab should be lazy loaded.

Actual behaviour

Tab information loads immediately on application load.

Steps to reproduce

I'm using this code:

<Scene
            key="one"
            tabs
            tabBarComponent={TabBarBottom}
            duration={1}
          >
            <Stack
              key="scene1"
              icon={MessageTab}
              title="scene1"
              hideNavBar
              lazy
            >
              <Scene
                key="subscene1"
                component={Subschene1}
                lazy
                title="subscene1"
                hideNavBar
              />
 </Stack>
 </Scene>
@aksonov
Copy link
Owner

aksonov commented Aug 29, 2017

It is first tab, what do you expect? It will be loaded because it is first.

@aksonov aksonov closed this as completed Aug 29, 2017
@ValentinBlokhin
Copy link
Author

It's not first tab, I removed some tabs from code example, it's 3 tab

@aksonov
Copy link
Owner

aksonov commented Aug 29, 2017

lazy doesn't work for containers, only for scenes - check lazy docs for TabNavigator (react-navigation).

@hugoh59
Copy link

hugoh59 commented Jan 5, 2018

lazy doesnt work for me, I've set it up in a scene and it's not working....

<Scene lazy key="auth" component={Auth} title="Facebook login"/>

@digitaldavenyc
Copy link

digitaldavenyc commented Feb 27, 2018

@aksonov lazy doesn't seem to be working for Scenes either, there's a duplicate issue open on it: #2846

Just to be clear, this should work right?

<Stack key="messages"
	icon={MessagesTab}
>
	<Scene key="messages"
		title="Messages"
		component={Messages}
		lazy={true}
		initial={true}
	/>
	<Scene key="channel"
		component={Channel}
		hideNavBar={true}
		hideTabBar={true}
	/>
</Stack>

@digitaldavenyc
Copy link

Anyone else experiencing this? It's causing some serious performance problems for us

@Samesh
Copy link

Samesh commented Mar 19, 2018

Yeap doesn't work properly, I'm guessing. Just in case, this is my code
Doesn't load on initial refresh, but keeps loading when navigating to a sister route. When I navigate to home, the friends component is mounted. I even tried adding tabs to all scenes. Still doesn't work. Please let me know if anyone finds a solution to this.
<Provider store={store}> <RouterWithRedux> <Scene key="root"> <Scene tabs={true} tabBarComponent={BottomNavigation} tabBarPosition="bottom" lazy={true} > <Scene key="profile" path="/profile/:userId" component={PostProfileContainer}/> <Scene key="reviewers" path="/reviewers/:userId" component={ReviewersProfileContainer} title="Reviewers" back={true}/> <Scene key="home" component={HomePageContainer}/> </Scene> <Scene key="signUp" component={SignUp} title="SignUp"/> <Scene key="traitsSelect" component={TraitsPageContainer} hideNavBar/> <Scene key="landing" component={LandingPageContainer} hideNavBar/> </Scene> </RouterWithRedux> </Provider>

@Samesh
Copy link

Samesh commented Mar 19, 2018

Hey animationEnabled={false} worked for me.

@digitaldavenyc
Copy link

@Samesh I tried adding animationEnabled={false} to a <Stack> and doesn't fix anything.... I'm getting so frustrated by this debating ripping out RNRF and just using React Navigation straight up

@Samesh
Copy link

Samesh commented Apr 25, 2018

`


<Stack key="createPost" hideNavBar titleStyle={{ alignSelf: 'center' }}>
<Scene
key="createPostModal"
component={CreatePostSelectType}
title="Login"
onExit={() => console.log('onExit')}
leftTitle="Cancel"
onLeft={Actions.pop}
/>

                <Scene key="root">
                    <Scene hideNavBar panHandlers={null}>
                        <Tabs
                            key="tabbar"
                            showLabel={false}
                            tabBarComponent={BottomNavigation}
                            tabBarPosition="bottom"
                            animationEnabled={false}
                            lazy
                        >
                            <Stack key="tab_1">
                                <Scene key="home" component={HomePageContainer} hideNavBar/>
                                <Scene key="comments" path="/comments/:postIdParam" component={CommentsContainer} title="Comments" hideTabBar/>
                                <Scene key="notifications" component={NotificationsContainer} title="Notifications"/>
                                <Scene key="singlePost" component={SinglePagePostContainer}/>
                                <Scene key="pendingComments" path="/pending_comments/:postIdParam" component={PendingCommentsContainer} title="Pending comments" hideTabBar/>
                                <Scene key="search" component={SearchPageContainer} navBar={SearchNavBar}/>
                                <Scene key="profile" path="/profile/posts/:userIdParam" component={PostProfileContainer}/>
                                <Scene key="reviewers" path="/profile/reviewers/:userIdParam" component={ReviewersProfileContainer} title="Reviewers"/>
                            </Stack>

                        </Tabs>
                        <Scene key="signUp" component={SignUp} title="SignUp"/>
                        <Scene key="traitsSelect" component={TraitsPageContainer} hideNavBar/>
                        <Scene key="landing" component={LandingPageContainer} hideNavBar/>
                    </Scene>
                </Scene>

                </Modal>
            </RouterWithRedux>
        </Provider>`

This is what works for me @digitaldavenyc. I don't really understand well as to how this works either but one thing is that the first nested route is rendered initially.

@wmonecke
Copy link

Not working for me neither. Trying to implement RAM Modules and this is a bottleneck in performance.

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

6 participants