1

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!

1 Answer 1

1

Using react-codemon, run on your projects directory

jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js myapp/

This will resolve updating proptypes for your source code and any node modules.

Re-installing node modules will require running the command again it seems.

Please follow instructions over at https://github.com/reactjs/react-codemod but essentially once you've installed jscodeshift, and you've downloaded the react-codemod files as above for the various commands such as transforming React.propTypes to PropTypes and so on.

myapp/ here corresponds to my entire application project directory so the entire react-native project.

Secondly, consider the project dependencies you're using. For example in my case I was using react-native-router-flux at version 0.38.0, the app would work in debug mode, but crash in release. I attempted to upgrade to the latest beta version of 4.0.0-beta.24 and the problem was resolved.

Sign up to request clarification or add additional context in comments.

8 Comments

Hi @DineshSpartacus I've updated the answer, I hope it helps but basically install jscodeshift, download react-codemod transformation files over at github.com/reactjs/react-codemod and specify your projects directory at the end.
thanx fro reply but I am facing this issue when I am trying to use flux..previous i have used flux in another project perfectly but now I am trying to add Router it's showing above error and without using router flux it's working fine...I don't know what is going wrong. I wasted two days on this .
@DineshSpartacus Hello, I've added some more details to the answer, in my case it seems related to that I was using 0.38.0 and the issues seems to have been resolved in the latest beta version. To add, I don't know how much time went by in hope that the release app would just start up successfully, there was no obvious reason, no indication, until I looked in Android Device Monitor for when running the release build seeing things related to react-native-router-flux
Sorry I forgot to mention that I have resolved that issue....and all thanks to you......you answer should be accepted so other can follow your answer as I was hesitating to follow your answer in starting :p
Hey Michael send me your gmail id so I can share some details with you ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.