React-Native-ViewPager icon indicating copy to clipboard operation
React-Native-ViewPager copied to clipboard

How to load the page only when user selects the tab ?

Open infaz opened this issue 6 years ago • 3 comments

How to load the page only when user selects the tab. Currently, It loads all the views initially. I want to load each view when user select each tab.

infaz avatar Apr 29 '19 11:04 infaz

Hi @infaz have you find any the solution for this. I am also going through the same problem.

shivamtiwari8736 avatar Jul 11 '19 12:07 shivamtiwari8736

You can create a placeholder view first. Then observe for current page changed then init the component yourself.

<IndicatorViewPager
    onPageSelected={params => {
        setCurrentPage(params.position);
    }}
>
                <View style={{ width }}>
                    <YourFirstPage />
                </View>
                <View style={{ width }}>
                    {isSecondPageInitialized && <YourSecondPage />}
                </View>
</IndicatorViewPager>

r0b0t3d avatar Jul 30 '19 05:07 r0b0t3d

Ok thanks. I will try this.

shivamtiwari8736 avatar Jul 30 '19 05:07 shivamtiwari8736