2016-02-08 8 views
5

मैं एक जगह नहीं पकड़ सकता, जहां मैं गलती हूं।प्रोप टाइप परिभाषित, लेकिन कभी भी उपयोग नहीं किया गया (ESLint, babel 6)

preLoaders: [ 
    { 
    test: /\.js$/, 
    loaders: ['eslint'], 
    include: [ 
     path.resolve(__dirname, "src"), 
    ], 
    } 
], 

और मेरे घटक

import React, { PropTypes, Component } from 'react' 

export default class User extends Component { 
    render() { 
    const { name } = this.props 
    return <div> 
     <p>Hello, {name}!</p> 
    </div> 
    } 
} 

User.propTypes = { 
    name: React.PropTypes.string.isRequired 
} 

मैं अपवाद: 01:17 त्रुटि "PropTypes

मेरी .eslintrc

{ 
    "extends": "eslint:recommended", 
    "parser": "babel-eslint", 
    "env": { 
    "browser": true, 
    "node": true 
    }, 
    "plugins": [ 
    "react" 
    ], 
    "rules": { 
    "no-console": 0, 
    "new-cap": 0, 
    "strict": 0, 
    "no-underscore-dangle": 0, 
    "no-use-before-define": 0, 
    "eol-last": 0, 
    "quotes": [2, "single"], 
    "jsx-quotes": 1, 
    "react/jsx-no-undef": 1, 
    "react/jsx-uses-react": 1, 
    "react/jsx-uses-vars": 1 
    } 
} 

मेरे webpack.config फाहा के बारे में खंड "परिभाषित किया गया है लेकिन कभी भी अप्रयुक्त-वर्र्स का उपयोग नहीं किया गया

हम्म, मैं क्या गलत कर रहा हूं?

पीएस Babel5 के साथ - सभी सही ढंग से काम करता है।

उत्तर

11
User.propTypes = { 
    name: React.PropTypes.string.isRequired 
} 

आप पहले से ही PropTypes रूप React.PropTypes आयात कर रहे हैं, इसलिए इस मामले में, बस name: PropTypes.string.isRequired के लिए इसे बदल (या निकालने PropTypes शीर्ष पर आयात)

+0

धन्यवाद, यह मुझे पागल गाड़ी चला रहा था –

संबंधित मुद्दे

 संबंधित मुद्दे