小编典典

反应-未捕获的TypeError:无法读取未定义的属性'func'

reactjs

我收到错误:

未捕获的TypeError:无法读取未定义的属性’func’

但是我不知道为什么,我用Google搜索了这个错误,并以相同的错误去了每个人的帖子,但是没有运气。谁能帮我吗?

我正在使用[email protected]

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;

最初,我没有导入PropType,因为我还不需要它。


阅读 240

收藏
2020-07-22

共1个答案

小编典典

它看起来像一个react-router bug(与道具类型有关)。它正在react-router 3.2.0上运行

在此处检查问题:https :
//github.com/ReactTraining/react-
router/issues/5605

2020-07-22