I have a problem with PropTypes in react native my code :
import React, { Component, PropTypes } from 'react';
import { Text } from 'react-native';
export default class Star extends Component {
    render() {
        return ( <Text> Hello </Text> );
    }
}
Star.propTypes = {
    fullStar: PropTypes.string.isRequired,
    halfStar: PropTypes.string.isRequired,
    emptyStar: PropTypes.string.isRequired,
    half: PropTypes.bool,
    count: PropTypes.number,
    size: PropTypes.number,
}
Star.defaultProps = {
    fullStar: "",
    halfStar: "",
    emtyStar: "",
    half: 'true',
    count: 5,
    size: 30,
}
My error is undefined is not an object (evaluating '_react2.PropTypes.string')
Thanks for read ;)
PropTypes moved into separate package. Use prop-types package.
More info here.
Note:
React.PropTypeshas moved into a different package since React v15.5. Please use the prop-types library instead. We provide a codemod script to automate the conversion.
Yes, PropTypes has been deprecated from version 15.x you need to install the package:
npm install prop-types
and then import it.
import PropTypes from 'prop-types';
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With