反应道具类型错误 [英] React prop-types error

查看:90
本文介绍了反应道具类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 codepen 中创建网络应用程序.我正在使用 React,ReactDOM.一切都很好.但是当我将 react-router-dom 添加到我的项目中时,出现错误:

I'm trying to create web app in codepen. I'm using React, ReactDOM. All was fine. But when I added react-router-dom to my project, I got an error:

react-router-dom.min.js:1 Uncaught Error: Cannot find module "prop-types"

我该如何解决这个问题?

How can I fix this?

推荐答案

从 React 15.5.0 开始,PropTypes 已作为单独的依赖项从 React 核心包中删除.要解决此问题,请将 prop-types 添加到您的代码中:

As of React 15.5.0, PropTypes have been removed from the core React package as a separate dependency. To fix this, add prop-types into your code:

如果您通过脚本标签加载:

If you're loading via script tags:

<script src="https://unpkg.com/prop-types/prop-types.min.js"></script>

或者通过 NPM:

npm install --save prop-types

这篇关于反应道具类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆