javascript – React – Uncaught TypeError:无法读取未定义的属性’func’

我收到错误:

Uncaught TypeError: Cannot read property ‘func’ of undefined

然而我不知道为什么,我已经用Google搜索了错误,并以相同的错误去了所有人的帖子但没有运气.谁能帮我吗?

我正在使用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;

最初我没有导入PropTypes,因为我还不需要它.

解决方法:

它看起来像一个反应路由器错误(与道具类型有关.)它正在反应路由器3.2.0上工作

在这里查看问题:
https://github.com/ReactTraining/react-router/issues/5605

上一篇:好程序员web学习路线初步认知react框架


下一篇:什么是jsx