反应-未捕获的TypeError:无法读取未定义的属性'func' [英] React - Uncaught TypeError: Cannot read property 'func' of undefined

查看:99
本文介绍了反应-未捕获的TypeError:无法读取未定义的属性'func'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:

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

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?

我正在使用react-router@3.0.2

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;

最初,我尚未导入PropType,因为我还不需要它.

Originally I didn't import PropTypes because I don't need it, yet.

推荐答案

它看起来像一个react-router的bug(与道具类型有关.)它在react-router 3.2.0上工作.

It looks like a react-router bug (related to prop types.) It's working on react-router 3.2.0

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

这篇关于反应-未捕获的TypeError:无法读取未定义的属性'func'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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