React-Native 16 Alpha 12 Migrating PropTypes

507 views Asked by At

My Expo XDE is giving me the following warning on a newly created project:

1:37:35 PM Warning: checkPropTypes has been moved to a separate package. Accessing React.checkPropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.

1:37:35 PM Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.

1:37:35 PM Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.

Migrating Prop-Types

Even though my code seems to be fine.. does anyone know why I still get this message or what is wrong with the following code?

Code

import React, {Component} from 'react';
import Root from './src/Root';
import {View} from 'react-native';
import PropTypes from 'prop-types';

class App extends Component {
  render() {
    return (<View />);
  }
}

App.PropTypes = {}

export default App;

package.json

{
  "name": "WeDo",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.2.1",
    "jest-expo": "~20.0.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^20.0.0",
    "prop-types": "^15.5.10",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.47.0"
  }
}
2

There are 2 answers

3
Andy On BEST ANSWER

The property on App should be propTypes not PropTypes. You still use PropTypes within the object, however.

For example:

App.propTypes = {
  name: PropTypes.string.isRequired
}
0
visortelle On

You can use https://github.com/reactjs/react-codemod#react-proptypes-to-prop-types to replace imports from React.PropTypes to 'prop-types'