Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Access Child Screen Props From React Navigation Top Tabs

$
0
0

I'm using Typescript and since this question is more theoretical, I will only post the necessary code.I have a material top tab navigation looking like this:

TabNavigator.tsx

const Tab = createMaterialTopTabNavigator<GameTabParamList>();const GameTabs: FC = () => {  return (<Tab.Navigator      initialRouteName={Screens.HOME_SCREEN}      tabBarPosition="bottom"      screenOptions={{        lazy: true,        tabBarStyle: {display: 'none'},        swipeEnabled: false, // This should be equal to props that are found in the multiple screens      }}      backBehavior='none'><Tab.Screen        name={Screens.AVAILABLE_PRIZES_SCREEN}        component={AvailablePrizesScreen}      /><Tab.Screen name={Screens.HOME_SCREEN} component={HomeScreen} /><Tab.Screen        name={Screens.WON_PRIZES_SCREEN}        component={WonPrizesScreen}      /></Tab.Navigator>  );};

HomeScreen.txs

const HomeScreen: FC = () => {  const {    isInitialized,    isLoading,    adShowing,    playGame,    localCount,    isAnimationPlaying,    winAnimationRef,    handleWinAnimationFinished,    isFlashAnimationPlaying,    navToSettingsScreen,    displayPrizeId,    displayPrizeTitle,    displayPrizeDesc,    displayPrizeTier,    displayPrizeType,    isShowingPrize,    handleHidePrize,    handleFlashAnimationFinished,    navigation,  } = useHomeScreen();...}

The goal is to make the swipeEnabled equal to the HomeScreen's isloading and isInitialized variables. So it should look like this:

TabNavigator.tsx

      screenOptions={{        lazy: true,        tabBarStyle: {display: 'none'},        swipeEnabled: !isLoading || !isInitialized, // <-- how do I get this here?      }}

The problem is, how do I get the isLoading and isInitialized variables from the HomeScreen component to the GameTabs component?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>