From 4b6d8f311239a5cc5e68dc06f3a0593c1c0b64d7 Mon Sep 17 00:00:00 2001 From: Gaya Blau <86973357+gayablau@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:08:12 +0300 Subject: [PATCH] Fix/tab page nested in scroll view (#3224) * fix tab page nested in scroll view * clean * expand to style prop * change prop name --- src/components/tabController/TabPage.tsx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/tabController/TabPage.tsx b/src/components/tabController/TabPage.tsx index eddf6f4667..09d6fa014d 100644 --- a/src/components/tabController/TabPage.tsx +++ b/src/components/tabController/TabPage.tsx @@ -1,5 +1,5 @@ import React, {PropsWithChildren, useCallback, useContext, useState, useMemo} from 'react'; -import {StyleSheet} from 'react-native'; +import {type StyleProp, StyleSheet, type ViewStyle} from 'react-native'; import Reanimated, {useAnimatedStyle, useAnimatedReaction, runOnJS} from 'react-native-reanimated'; // import {Freeze} from 'react-freeze'; import TabBarContext from './TabBarContext'; @@ -25,6 +25,10 @@ export interface TabControllerPageProps { * Used as a testing identifier */ testID?: string; + /** + * add style properties to tab page + */ + style?: StyleProp; } /** @@ -36,6 +40,7 @@ export default function TabPage({ index, lazy, renderLoading, + style, lazyLoadTime = 100, ...props }: PropsWithChildren) { @@ -81,12 +86,17 @@ export default function TabPage({ }; }); - const style = useMemo(() => { - return [!asCarousel && styles.page, animatedPageStyle, {width: asCarousel ? containerWidth : undefined}]; - }, [asCarousel, animatedPageStyle, containerWidth]); + const _style = useMemo(() => { + return [ + !asCarousel && styles.page, + animatedPageStyle, + {width: asCarousel ? containerWidth : undefined}, + style + ]; + }, [asCarousel, animatedPageStyle, containerWidth, style]); return ( - + {!shouldLoad && renderLoading?.()} {shouldLoad && props.children} {/* {props.children} */}