react: 使用PropTypes 进行类型检查时控制台报:TypeError: Cannot read property ‘string‘ of undefined
2020-08-14 21:08
886 查看
查询资料知,从 React v15.5 开始 ,React.PropTypes 助手函数已被弃用,建议使用 prop-types 库 来定义contextTypes。
需要将React.PropTypes.string修改为PropTypes.string。
同时必须引入prop-types.js这个库,
<script type="text/javascript" src="../js/prop-types.js"></script>
相关文章推荐
- 使用 PropTypes 进行类型检 || 控制台报:TypeError: Cannot read property 'string' of undefined)
- TypeError: Cannot read property 'gc' of undefined 使用百度地图报错
- 使用npm run build 打包时报错: TypeError: Cannot read property 'compilation' of undefined
- vuejs路由使用的问题Error in render function: "TypeError: Cannot read property 'matched' of undefined"
- angular和datatables一起使用的时候,出现TypeError: Cannot Read Property "childNodes" Of Undefined In AngularJS...
- 使用JQuery插件DataTables,报错:Uncaught TypeError: Cannot read property 'length' of undefined
- iview-admin中使用组件报错TypeError: Cannot read property '_t' of undefined
- 使用form的方法(例如:reset,clear等)报错Uncaught TypeError: Cannot read property 'tip' of undefined(…)的原因
- 关于Uncaught TypeError: Cannot read property 'toLowerCase' of undefined的问题
- vue-cli3的项目 CDN链接报错解决 Uncaught TypeError: Cannot read property 'prototype' of undefined at Object.
- Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'number' of undefined
- XX商城all.js:329 Uncaught TypeError: Cannot read property 'offse 4000 tWidth' of undefined
- extjs4:Uncaught TypeError: Cannot read property 'processed' of undefined
- 使用UEditor的setContent的时候报错,报错代码如下 Uncaught TypeError: Cannot set property 'innerHTML' of undefined 错
- angular 1做项目时 报错TypeError: Cannot read property 'then' of undefined
- vue 国际化在弹出框中$t()报错:TypeError: Cannot read property '_t' of undefined
- util.js:68 Uncaught TypeError: Cannot read property 'fn' of undefined
- JQuery zTree Uncaught TypeError: Cannot read property 'init' of undefined
- 使用ELEMENT-UI时前端报错:Uncaught TypeError: Cannot read property 'disabled' of null