尝试将一些自定义样式应用于 UI-Kitten 底部标签栏并获得“无效的挂钩调用”错误。
- 它是一个功能组件。
- 我不认为我有多个反应实例。
npm ls react
只显示一个实例。 - 我在同一个应用程序的不同组件上使用这个相同的钩子没有问题。
- 整个应用程序中的其他钩子用法也很好。
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
...
function BottomTabBar({navigation, state}) {
const myStyles = useStyleSheet(themedStyles);
const onSelect = (index) => {
navigation.navigate(state.routeNames[index]);
};
return (
<BottomNavigation selectedIndex={state.index} onSelect={onSelect} style={myStyles.bottomNav}>
<BottomNavigationTab icon={HomeIcon} title="Home" />
<BottomNavigationTab icon={CreateIcon} title="CreateThing" />
<BottomNavigationTab icon={SettingIcon} title="Settings" />
</BottomNavigation>
);
}
...
const BottomTab = createBottomTabNavigator();
const TabNavigator = () => {
return (
<BottomTab.Navigator initialRouteName="Home" tabBar={BottomTabBar}>
<BottomTab.Screen name="Home" component={Home} />
<BottomTab.Screen name="CreateThing" component={CreateThing} />
<BottomTab.Screen name="Settings" component={Settings} />
</BottomTab.Navigator>
);
};
const themedStyles = StyleService.create({
bottomNav: {
backgroundColor: 'color-primary-default',
},
});
export default TabNavigator;
对我来说,钩子似乎没有违反任何规则。有什么想法吗?