未定义“属性” [英] 'Proptypes' is not defined
问题描述
我将在以下帮助下设置新的React: https://github.com / facebookincubator / create-react-app
I'm setting up a new React with the help of: https://github.com/facebookincubator/create-react-app
但是,我遇到了皮毛问题。我收到以下提示错误 PropTypes未定义。 (no-undef)
。
However, I'm running into a linting issue. I'm receiving the following linting error 'PropTypes' is not defined. (no-undef)
.
以下是引起问题的代码:
Here is the code that is causing the issue:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Routers extends Component {
static propTypes = {
history: PropTypes.object.isRequired
};
...
我尝试使用 react / prop-types 规则,但是没用。
I tried playing around with the react/prop-types rule, but to no avail.
推荐答案
根据此问题评论。
这似乎是因为您安装了 eslint 4.x
时,您只应使用 create-react-app 。您应该删除所有手动安装的eslint,然后使用存储库随附的那个。
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.
这篇关于未定义“属性”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!