[英]React-Navigation jumpToIndex undefined
I am getting this error .我收到此错误。 I am trying to make user press on tabbar and the content scrolls to the top but I am getting jumpToIndex is not a function
我试图让用户按下 tabbar 并且内容滚动到顶部,但我得到 jumpToIndex 不是一个函数
This is my code:这是我的代码:
const NavigationBar = createBottomTabNavigator({
Home: {
screen: HomeNav, navigationOptions: ({ navigation }) => ({
title: 'Home',
tabBarOnPress: (scene, jumpToIndex) => {
console.log('onPress:', scene.route);
jumpToIndex(scene.index);
},
}),
}
})
根据您的 react-navigation 活动版本, jumpToIndex
方法可能会贬值,您可以在此处访问文档https://reactnavigation.org/docs/bottom-tab-navigator/#tabpress了解如何在选项卡jumpToIndex
后滚动到顶部专注。
I guess you are using react native navigation v4, but your code is deprecated我猜您正在使用 react native navigation v4,但您的代码已被弃用
https://reactnavigation.org/docs/4.x/material-bottom-tab-navigator/#tabbaronpress https://reactnavigation.org/docs/4.x/material-bottom-tab-navigator/#tabbaronpress
const NavigationBar = createBottomTabNavigator({
Home: {
screen: HomeNav, navigationOptions: ({ navigation }) => ({
title: 'Home',
tabBarOnPress: ({navigation, defaultHandler}) => {
// your logic
},
}),
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.