question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NavigatorIOS doesn't work on React Native 0.62.2

See original GitHub issue

Description

I have created a sample React Native 0.62.2 project. The NavigatorIOS component doesn’t seem to work. I’m adding the code and the package.json below.

React Native version:

0.62.2

Steps To Reproduce

  1. Create new project with npx react-native init AwesomeProject
  2. Add prop types dependency npm install --save prop-types
  3. Build the sample code as mentioned in the code section. (NavigatorIOS code is from React Native Devs - NavigatorIOS
  4. Run the app from workspace on XCode

Expected Results

NavigatorIOS should navigate to the initial scene page.

Snack, code example, screenshot, or link to a repository:

Snack Link: Demo on Expo

index.js

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

App.js

import React, {Component} from 'react';
import {NavigatorIOS} from 'react-native';
import MyScene from './MyScene';

export default class App extends Component {
  render() {
    return (
      <NavigatorIOS
        initialRoute={{
          component: MyScene,
          title: 'My Initial Scene',
        }}
        style={{flex: 1}}
      />
    );
  }
}

MyScene.js

import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {Text, TouchableHighlight, View} from 'react-native';

export default class MyScene extends Component {
  static propTypes = {
    title: PropTypes.string.isRequired,
    navigator: PropTypes.object.isRequired,
  };

  _onForward = () => {
    this.props.navigator.push({
      title: 'Scene',
    });
  };

  render() {
    return (
      <View>
        <Text>Current Scene: {this.props.title}</Text>
        <TouchableHighlight onPress={this._onForward}>
          <Text>Tap me to load the next scene</Text>
        </TouchableHighlight>
      </View>
    );
  }
}

package.json

{
  "name": "AwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "prop-types": "^15.7.2",
    "react": "16.11.0",
    "react-native": "0.62.2"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.4.0",
    "eslint": "^6.8.0",
    "jest": "^25.4.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Error Stack

2020-04-22 10:37:55.758 [warn][tid:com.facebook.react.JavaScript] ‘Warning: React.createElement: type is invalid – expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s’, ‘undefined’, ’ You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.\n\nCheck your code at App.js:16.‘, ‘\n in App (at renderApplication.js:45)\n in RCTView (at AppContainer.js:109)\n in RCTView (at AppContainer.js:135)\n in AppContainer (at renderApplication.js:39)’ 2020-04-22 10:37:55.759 [warn][tid:com.facebook.react.JavaScript] ‘Warning: React.createElement: type is invalid – expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s%s’, ‘undefined’, ’ You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.\n\nCheck your code at App.js:16.’, ‘\n in App (at renderApplication.js:45)\n in RCTView (at AppContainer.js:109)\n in RCTView (at AppContainer.js:135)\n in AppContainer (at renderApplication.js:39)’ 2020-04-22 10:37:55.763 [error][tid:com.facebook.react.JavaScript] Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.

Check the render method of App.

This error is located at: in App (at renderApplication.js:45) in RCTView (at AppContainer.js:109) in RCTView (at AppContainer.js:135) in AppContainer (at renderApplication.js:39) 2020-04-22 10:37:55.774 [error][tid:com.facebook.react.JavaScript] Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.

Check the render method of App.

This error is located at: in App (at renderApplication.js:45) in RCTView (at AppContainer.js:109) in RCTView (at AppContainer.js:135) in AppContainer (at renderApplication.js:39) 2020-04-22 10:37:55.779 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.

Check the render method of App.

This error is located at: in App (at renderApplication.js:45) in RCTView (at AppContainer.js:109) in RCTView (at AppContainer.js:135) in AppContainer (at renderApplication.js:39)

What’s causing this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vonovakcommented, May 24, 2020

Just a reminder that the docs are open source and anyone can contribute to them 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - React Navigation
Troubleshooting. This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation.
Read more >
Upgrading to new versions - React Native
Upgrading to new versions of React Native will give you access to more APIs, views, developer tools and other goodies.
Read more >
react-native-screens - npm
This project aims to expose native navigation container components to React Native. It is not designed to be used as a standalone library ......
Read more >
Upgrade to React Native 0.62 - Matt Oakes
React Native 0.62 has been a long time coming and brings many changes, large and small. This article explains what's new, how to...
Read more >
Deep linking in IOS with react navigation does not route to the ...
I have set up deep linking in my project with react-navigation. It is successfully working in android. But in ios, it is opening...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found