最近在使用RN中发现navigator已经被废弃了,不知道facebook搞什么,网上百度了一下没找到合适的tips,试了几个也没成功,最后在GitHub上找打了相应的解决方案。
https://github.com/react-community/react-navigation/issues/1328
步骤一:
npm install react-native-deprecated-custom-components --save
步骤二:
在项目中引用
import NavigationExperimental from 'react-native-deprecated-custom-components';
步骤三:
使用
export default class App extends Component {
render() {
return (
<NavigationExperimental.Navigator
// Default to movies route
initialRoute={{ name: 'movies' }}
// Use FloatFromBottom transition between screens
configureScene={(route, routeStack) => NavigationExperimental.Navigator.SceneConfigs.FloatFromBottom}
// Pass a route mapper functions
renderScene={RouteMapper}
/>
);
}
}
网友评论