'Proptypes' is not defined

前端 未结 7 798
面向向阳花
面向向阳花 2020-12-30 20:39

I\'m setting up a new React with the help of: https://github.com/facebookincubator/create-react-app

However, I\'m running into a linting issue. I\'m receiving the fo

相关标签:
7条回答
  • 2020-12-30 21:23

    If you're using <script> tags; you can add this tag:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js" integrity="sha512-ssNhh7jlzc+K93ckIlSXFHHz6fSFv0l619WOv8xbFNRbFOujbasb42LVMOggDrQR1ScJncoWb+KAJx1uF3ipjw==" crossorigin="anonymous"></script>
    
    

    You can get the minified/non-minified and other version here

    Good Luck...

    0 讨论(0)
  • 2020-12-30 21:25

    According to this issue comment.

    It appears to be because you have installed eslint 4.x when you should just use the eslint version that is shipped with create-react-app. You should remove any eslint you have manually installed and use the one that comes with the repo.

    0 讨论(0)
  • 2020-12-30 21:25

    Please install the prop-types npm package - react 1.15 and greater on separate package is created.

    Here to install package

    0 讨论(0)
  • 2020-12-30 21:31

    You can place the PropTypes just after the class (outside the class):

    Routers.propTypes = {
       history: PropTypes.object.isRequired
    }
    
    0 讨论(0)
  • 2020-12-30 21:39

    Please Install prop-types

    using this code : npm install --save prop-types

    0 讨论(0)
  • 2020-12-30 21:42

    Since react 15.5, PropTypes is included in a separate package, 'prop-types'. So this line will help

    import PropTypes from 'prop-types'
    

    You can read more here

    0 讨论(0)
提交回复
热议问题