【发布时间】:2022-06-15 21:36:56
【问题描述】:
我正在使用材质顶部标签导航器 https://reactnavigation.org/docs/material-top-tab-navigator
当我切换标签时,组件总是被重新渲染。 如何防止重新渲染?
这是我的代码 请帮帮我!!!!
const Menu = () => {
return (...)
}
const Info = () => {
return (...)
}
const Review = () => {
return (...)
}
<Tab.Navigator
screenOptions={{
tabBarScrollEnabled: false,
tabBarStyle: { backgroundColor: '#FFFFFF' },
tabBarPressOpacity: true
}}
style={styles.tabBar}
>
<Tab.Screen
name="Menu"
component={Menu}
options={{
tabBarShowLabel: false,
tabBarIcon: ({ forcused, color }) => {
return <Text style={styles.tabBarText}>메뉴</Text>;
},
}}
/>
<Tab.Screen
name="Info"
component={Info}
options={{
tabBarShowLabel: false,
tabBarIcon: ({ forcused, color }) => {
return <Text style={styles.tabBarText}>정보</Text>;
},
}}
/>
<Tab.Screen
name="Review"
component={Review}
options={{
tabBarShowLabel: false,
tabBarIcon: ({ forcused, color }) => {
return <Text style={styles.tabBarText}>리뷰</Text>;
},
}}
/>
</Tab.Navigator>
【问题讨论】:
标签: reactjs react-native