反应 - 未捕获的类型错误:无法读取未定义的属性“func" [英] React - Uncaught TypeError: Cannot read property 'func' of undefined
问题描述
我收到错误:
<块引用>未捕获的类型错误:无法读取未定义的属性 'func'
但我不知道为什么,我已经在谷歌上搜索了错误,并给每个人发了同样的错误,但没有运气.谁能帮帮我?
我正在使用 react-router@3.0.2
index.jsx
从'react'导入React;从 'react-dom' 导入 ReactDOM;从反应路由器"导入{路由器,浏览器历史};从反应头盔"导入{头盔};从./config/routes"导入路由;ReactDOM.render(<div><头盔><meta charSet='utf-8'/><title>斯凯尔顿</title><link rel='icon' href='images/favicon.png'/><link rel='stylesheet' href='style.css'/></头盔><Router routes={Routes()} history={browserHistory}/>
, document.getElementById('root'));
route.js
从'react'导入React;从反应路由器"导入 { Route, IndexRoute };从 '../pages/Example1' 导入 Example1;出口功能路线(){返回 (<路线><Route path='/' component={Example1}/><IndexRoute 组件={Example1}/></路线>);}导出默认路由;
Example1.js
import React, { Component } from 'react';从 'prop-types' 导入 PropTypes;类 Example1 扩展组件 {使成为() {返回 (<div><h1>你好,世界!这是实施例1.
);}}导出默认示例1;
最初我没有导入 PropTypes,因为我还不需要它.
它看起来像一个 react-router 错误(与 prop 类型有关.)它正在开发 react-router 3.2.0
在这里检查问题:https://github.com/ReactTraining/react-router/issues/5605
I'm receiving the error:
Uncaught TypeError: Cannot read property 'func' of undefined
Yet I have no idea why, I've Googled the error and gone to everyone post with the same error yet no luck. Can anyone help me out?
I'm using react-router@3.0.2
index.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import { Helmet } from 'react-helmet';
import Routes from './config/routes';
ReactDOM.render(
<div>
<Helmet>
<meta charSet='utf-8'/>
<title>Skelton</title>
<link rel='icon' href='images/favicon.png'/>
<link rel='stylesheet' href='style.css'/>
</Helmet>
<Router routes={Routes()} history={browserHistory}/>
</div>
, document.getElementById('root'));
route.js
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import Example1 from '../pages/Example1';
export function routes() {
return (
<Route>
<Route path='/' component={Example1}/>
<IndexRoute component={Example1}/>
</Route>
);
}
export default routes;
Example1.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Example1 extends Component {
render() {
return (
<div>
<h1>Hello World! This is Example 1.</h1>
</div>
);
}
}
export default Example1;
Originally I didn't import PropTypes because I don't need it, yet.
It looks like a react-router bug (related to prop types.) It's working on react-router 3.2.0
Check the issue here: https://github.com/ReactTraining/react-router/issues/5605
这篇关于反应 - 未捕获的类型错误:无法读取未定义的属性“func"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!