React-Native Navigator is deprecated and has been removed from this package

Viewed 12974

I get the following error.

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

Then I would update react-native-deprecated-custom-components package but issue not solved

Package.Json

"dependencies": {
    "react": "16.0.0-alpha.6",
    "react-native": "0.44.2",
    "react-native-deprecated-custom-components": "^0.1.0",
    "sendbird": "^3.0.30"
},

main.js

var React = require('react-native')
var {
  Navigator,
  StyleSheet
} = React;

var Login = require('./components/login');

import NavigationExperimental from 'react-native-deprecated-custom-components';

var ROUTES = {
  login: Login
};

module.exports = React.createClass({
  renderScene: function(route, navigator) {
    var Component = ROUTES[route.name];
    return <Component route={route} navigator={navigator} />;
  },
  render: function() {
    return (

      <NavigationExperimental.Navigator
        style={ styles.container }
        initialRoute={ {name: 'login'} }
        renderScene={this.renderScene}
        configureScene={ () => { return Navigator.SceneConfigs.FloatFromRight; } }
      />
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1
  }
});

Any one let me know to solve this issue

3 Answers

If anyone is seeing this while not even trying to use Navigator, it’s possibly because you’ve got an import line like

import * as RN from 'react-native'

(Webstorm in particular has a habit of auto-inserting these)

This calls the getters for all of RN’s exports, triggering the error for Navigator. Instead use:

import {Things, You, Need} from 'react-native'

Related