Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native: undefined is not an object (evaluating '_react2.PropTypes.string') #832

Closed
ghost opened this issue Dec 2, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 2, 2017

Hi there,

I've recently upgraded react-native

"react-native": "^0.50.4",

and react

"react": "^16.2.0",

I'm using mapbox additionally along with FBSDK, React-Native-Router-Flux, etc and I'm getting the following error

undefined is not an object (evaluating '_react2.PropTypes.string')

My package.json is as follows:

{
  "name": "clustr",
  "version": "0.9.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "remotedev": "remotedev --hostname=localhost --port=8000",
    "flow": "flow"
  },
  "dependencies": {
    "@mapbox/react-native-mapbox-gl": "^6.0.1",
    "fuzzysearch": "^1.0.3",
    "haversine": "^1.1.0",
    "lodash": "^4.17.4",
    "moment": "^2.19.3",
    "moment-business": "^3.0.1",
    "prop-types": "^15.6.0",
    "querystring": "^0.2.0",
    "react": "^16.2.0",
    "react-native": "^0.50.4",
    "react-native-branch": "^2.1.1",
    "react-native-camera": "^0.10.0",
    "react-native-device-info": "^0.10.2",
    "react-native-drawer-layout": "^1.3.0",
    "react-native-fbsdk": "^0.6.3",
    "react-native-geocoder": "^0.4.8",
    "react-native-hyperlink": "0.0.10",
    "react-native-i18n": "^1.0.0",
    "react-native-loading-spinner-overlay": "^0.5.2",
    "react-native-maps": "^0.17.1",
    "react-native-modalbox": "^1.3.8",
    "react-native-page-control": "^1.1.1",
    "react-native-qrcode": "^0.2.6",
    "react-native-qrcode-scanner": "0.0.22",
    "react-native-radio-buttons": "^0.14.0",
    "react-native-router-flux": "3.38.0",
    "react-native-swipe-gestures": "^1.0.2",
    "react-native-vector-icons": "^4.4.2",
    "react-redux": "^5.0.4",
    "redux": "^3.6.0",
    "redux-form": "^6.6.3",
    "redux-form-material-ui": "^4.3.1",
    "redux-saga": "^0.15.3",
    "remote-redux-devtools": "^0.5.7",
    "tipsi-stripe": "^3.9.1",
    "url-parse": "^1.1.9"
  },
  "devDependencies": {
    "babel-plugin-module-resolver": "^2.7.0",
    "flow-bin": "^0.45.0",
    "remotedev-server": "0.2.2"
  },
  "assets": [
    "./assets/fonts"
  ]
}

With the upgrade I've swapped over to using prop-types as follows:

import React from 'react';
import Text from '../generic/CText';
import {Platform, TouchableOpacity, View, Image} from 'react-native';
import PropTypes from 'prop-types';


TitleBar.propTypes = {
    title: PropTypes.string
};

export default TitleBar;

And so on, this is consistent across all of my components.

Thanks very much for your help!

@ghost
Copy link
Author

ghost commented Dec 2, 2017

Seems that running

jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js <path> on my project resolved the issue for the time being.

@nitaliano
Copy link
Owner

@MichaelStokes is the warning coming from this repo? We are using prop-types

@ghost
Copy link
Author

ghost commented Dec 4, 2017

@nitaliano It appears to be that the issue was coming from react-native-router-flux on version 0.38.0, it wasn't obvious at all, but after looking at the logs from Android Device Monitor when running the release build, I could see some related logs ... so I'd figure I'd upgrade react-native-router-flux to the latest build 4.0.0-beta.24 and the issue was resolved. Please see https://stackoverflow.com/questions/47603791/react-native-undefined-is-not-an-object-evaluating-react2-proptypes-string/47603838#47603838 for more details.

@nitaliano
Copy link
Owner

Cool, I'm going to close this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant