React-Native到0.44版本后Navigator 不能用的問題


新升級  到0.46版本以后 Navigator 不能使用報錯。

'Navigator is deprecated and has been removed from this package. It can now be installed ' +
           'and imported from `react-native-deprecated-custom-components` instead of `react-native`. ' +
          'Learn about alternative navigation solutions at http://facebook.github.io/react-native/docs/navigation.html'

 

解決方案:

  1、cd 當前目錄

  2、npm install react-native-deprecated-custom-components --save

  3、import {Navigator} from 'react-native-deprecated-custom-components';

  4、

          <Navigator 
            initialRoute={{ name: '首頁', component: Home }}
            //配置場景
            configureScene=
            {
              (route) => {

                //這個是頁面之間跳轉時候的動畫,具體有哪些?可以看這個目錄下,
                //有源代碼的: node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorSceneConfigs.js

                // return Navigator.SceneConfigs.PushFromRight;
                return ({
                  ...Navigator.SceneConfigs.PushFromRight,
                  gestures: null,
                });
              }
            }
            renderScene={
              (route, navigator) => {
                let Component = route.component;
                return <Component {...route.params} navigator={navigator} />
              }
            } />

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM