gpt4 book ai didi

reactjs - “Proptypes”未定义

转载 作者:行者123 更新时间:2023-12-03 13:02:36 28 4
gpt4 key购买 nike

我正在设置一个新的 React 在: Create React App 的帮助下

但是,我遇到了 linting 问题。我收到以下 linting 错误 'PropTypes' 未定义。 (无undef)

以下是导致问题的代码:

import React, { Component } from 'react';
import PropTypes from 'prop-types';

class Routers extends Component {
static propTypes = {
history: PropTypes.object.isRequired
};

...

我尝试使用 react/prop-types规则,但无济于事。

最佳答案

自 React 15.5 起,PropTypes 包含在单独的包“prop-types”中。所以这一行会有帮助

import PropTypes from 'prop-types'

您可以阅读更多here

关于reactjs - “Proptypes”未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45692537/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com