I am following the Redux Github repo's example/todomvc
and encountered the following issue:
[eslint] 'propTypes' is not defined. (no-undef)
The code related to this issue,
export default class Header extends Component {
static propTypes = {
addTodo: PropTypes.func.isRequired
}
handleSave = text => {
if (text.length !== 0) {
this.props.addTodo(text)
}
}
To reproduce the error, just
cd example/todomvc
npm install
npm start
And the program would be interrupted caused by compile error.
It seems to be a long unresolved issue related to create-react-app
, I've read this post which claimed to resolve the issue by changing eslint
version to 3.19.0
. However, create-react-app
did ship with eslint@3.19.0
, no need to change its version.
So what's the proper way to correct this issue ? It could be possible to:
- change static property by using
Header.propTypes
instead ofstatic
syntax
However that doesn't resolve the issue.