RN中navigator的使用
2017-05-27 本文已影响186人
mark666
800B6AB6-0BAD-41A1-A525-A35EDC04E2D0.png
最近在使用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}
/>
);
}
}