Search code examples
javascriptreactjsreact-nativeprototypeprototypejs

I have changed to PropTypes to "prop-types" but still get Error evaluating React.PropTypes


Environment:

OS: Linux 5.3 Node: 12.16.1 Yarn: 1.21.1 npm: 6.13.4 Watchman: 4.9.0 Xcode: N/A Android Studio: 3.5 AI-191.8026.42.35.5791312

Packages: (wanted => installed)
react: ^16.3.0-alpha.0 => 16.13.0
react-native: 0.55.0 => 0.55.0
"dependencies": {
    "prop-types": "^15.7.2",
    "react": "^16.3.0-alpha.0",
    "react-native": "0.55.0",
    "react-native-parabolic": "~1.1.1",
    "react-native-scrollable-tab-view": "~0.7.1",
    "react-native-swiper": "~1.5.4",
    "react-native-tab-navigator": "~0.3.3"
  }
export default class DefaultTabBar extends Component{

  constructor(){
    super()
  }

  static propTypes = {
    goToPage: PropTypes.func,
    activeTab: PropTypes.number,
    tabs: PropTypes.array,
    backgroundColor: PropTypes.string,
    activeTextColor: PropTypes.string,
    inactiveTextColor: PropTypes.string,
    textStyle: Text.propTypes.style,
    tabStyle: View.propTypes.style,
    renderTab: PropTypes.func,
    underlineStyle: View.propTypes.style,
  };

imgae: https://i.sstatic.net/RQYgY.jpg

How can i fix it?


Solution

  • You can using this:

    import PropTypes from 'prop-types';
    
    class Greeting extends React.Component {
      render() {
        return (
          <h1>Hello, {this.props.name}</h1>
        );
      }
    }
    
    Greeting.propTypes = {
      name: PropTypes.string
    };
    

    https://reactjs.org/docs/typechecking-with-proptypes.html