You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This wraps the pagerview into a separate component and looks for the children within the pagerview and based on that will memoize the components.
Motivation
I struggled to find a way of using the usePagerView hook without a mapping function. For example when you want to show multiple components. So I thought of this idea and I just wanted to share this with everyone :)
Let me know what you think about this! Maybe someone else has an even better alternative? Happy coding!
Related Issues
Issue right now (look at comment):
exportfunctionPagerHookExample(){const{ AnimatedPagerView, ref, ...rest}=usePagerView({pagesAmount: 10});return(<SafeAreaViewstyle={styles.container}><AnimatedPagerViewtestID="pager-view"ref={ref}style={styles.PagerView}initialPage={0}layoutDirection="ltr"overdrag={rest.overdragEnabled}scrollEnabled={rest.scrollEnabled}onPageScroll={rest.onPageScroll}onPageSelected={rest.onPageSelected}onPageScrollStateChanged={rest.onPageScrollStateChanged}pageMargin={10}orientation="horizontal">{useMemo(()=>rest.pages.map((_,index)=>(// We're mapping here, but what if we want to show multiple components?<ViewtestID="pager-view-content"key={index}style={{flex: 1,backgroundColor: '#fdc08e',alignItems: 'center',padding: 20,}}collapsable={false}><LikeCount/><TexttestID={`pageNumber${index}`}>{`page number ${index}`}</Text></View>)),[rest.pages])}</AnimatedPagerView><NavigationPanel{...rest}/></SafeAreaView>);}
Describe the feature
This wraps the pagerview into a separate component and looks for the children within the pagerview and based on that will memoize the components.
Motivation
I struggled to find a way of using the usePagerView hook without a mapping function. For example when you want to show multiple components. So I thought of this idea and I just wanted to share this with everyone :)
Let me know what you think about this! Maybe someone else has an even better alternative? Happy coding!
Related Issues
Issue right now (look at comment):
Step one: Create the component
Step two: use the component using the usePagerView hook
The text was updated successfully, but these errors were encountered: