Cannot read property 'string' of undefined | React.PropTypes | LayoutPropTypes.js

React.PropTypes is now deprecated:

Note: React.PropTypes is deprecated as of React v15.5. Please use the prop-types library instead.

You need to add the prop-types package separately now. The error most likely just started to show up because you deleted your node_modules folder and then reinstalled everything which upgraded your react version.


React is no more shipped with PropTypes. You will need to install it.

First install the prop-types package by running npm i prop-types --save.

Next use the prop-types package into your component like this:

import React from 'react'
import PropTypes from 'prop-types'

export const AwesomeComponent = props => {
    return(
        <h1>Hello {props.name}</h1>
    )
}

AwesomeComponent.propTypes = {
    name: PropTypes.string.isRequired
}

Or simply use an interface if you are using Typescript like this:

import * as React from 'react'

interface IAwesomeComponentProps {
    name: string
} 

export const AwesomeComponent: React.FC<IAwesomeComponentProps> = props => {
    return(
        <h1>Hello {props.name}</h1>
    )
}

Are you absolutely sure you are using react 16.0.0-alpha.12?

Check your package.json if you have a ^ before the react version, if you have, it probably have installed the latest react version, which currently is 16.0.0-alpha.13, in which it breaks as you say (just had the problem myself). Having the ^ before the version, allows it to install newer minor and patch versions. You can read more about it here.

To keep it at the exact version you specify, simply remove the ^ before the version, so that your package.json looks like this:

  "dependencies": {
    "react": "16.0.0-alpha.12",
    "react-native": "0.45.1",
  }

Remember to re-install your node_modules after your changes.