import React, { Component,useEffect } from 'react';
import 'react-native-gesture-handler';
import { SafeAreaView,StackLayout,Button,TouchableOpacity,Image,Text, View ,StyleSheet, Dimensions} from 'react-native'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import { useIsFocused,NavigationContainer } from '@react-navigation/native';
const Tab = createBottomTabNavigator();
const TopTabsGroup = createMaterialTopTabNavigator();
function BeritaTerkini (){
return(
<View>
<Text> Berita Terkini </Text>
</View>
)
}
function Terpopuler (){
return(
<View>
<Text> Terpopuler </Text>
</View>
)
}
function TopTabroup(props){
const { initialRouteName } = props;
return (
<TopTabsGroup.Navigator initialRouteName={"Berita Terkini"} >
<TopTabsGroup.Screen name='Berita Terkini' component={BeritaTerkini} />
<TopTabsGroup.Screen name='Terpopuler' component={Terpopuler}/>
</TopTabsGroup.Navigator>
)
}
function TabGroup (){
return(
<Tab.Navigator screenOptions={{
headerShown: false,
tabBarActiveTintColor :'red',
tabBarInactiveTintColor :'black',
}} >
<Tab.Screen name='Berita Terkini' component={TopTabroup}
options={{
tabBarLabel: 'BERITA TERKINI',
tabBarIcon: ({ color, size }) => (
<Icon name="home" color={color} size={20} />
),
}}
/>
<Tab.Screen name='Topik' component={Topik}
options={{
tabBarLabel: 'TOPIK',
tabBarIcon: ({ color, size }) => (
<Icon name="microphone" color={color} size={20} />
),
}}/>
)
}
export default class Home extends Component {
render() {
return (
<View style={styles.container}>
<View style={styles.Header}>
<Image style={styles.logo} source={require('../assets/logo.png')} />
</View>
<TabGroup/>
</View>
)
}
}
when I run the application and enter another page and return to the home page, the top tab navigation does not return to the first tab, but remains on the tab that was selected…I use react-native not expo
when I run the application and enter another page and return to the home page, the top tab navigation does not return to the first tab, but remains on the tab that was selected…I use react-native not expo
New contributor
Riki Roder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.