简体   繁体   English

在DefaultRoute中反应0.13.x _classCallCheck()'无法将类作为函数调用'

[英]React 0.13.x _classCallCheck() in DefaultRoute 'Cannot call a class as a function’

I'm using React 0.13.3 with Webpack 1.9.5 and traceur-loader 0.6.3 (tried babel-loader before that), getting TypeError thrown by _classCallCheck() in DefaultRoute 'Cannot call a class as a function'. 我在Webpack 1.9.5和traceur-loader 0.6.3(之前尝试过babel-loader)上使用React 0.13.3,在DefaultRoute'无法将类作为函数调用'中,_classCallCheck()抛出TypeError。 I don't see where I'm calling a class as a function. 我看不到将类作为函数调用的位置。 This is what my routes look like: 这是我的路线:

    var Application = require('./components/Application');
    var Home = require('./components/Home');
    var About = require('./components/About');
    var MainFeedVideos = require('./components/MainFeedVideos');
    var MyUploads = require('./components/MyUploads');
    ...
    var routes = (
            //logged out content
            <Route flux={flux} handler={Application}>
                <DefaultRoute handler={Home} />
                <Route name='about' handler={About}/>
                ...
                //logged in content
                <Route path='/' name='home' handler={Home}>
                    <DefaultRoute handler={MainFeedVideos} />
                    <Route name='my-videos' handler={MyUploads}/>
                    ...
                </Route>
            </Route>);

    Router.run(routes, Router.HistoryLocation, function (Handler) {
        React.render(<Handler/>, document.getElementById('content'));
    });

Anyone had this issue before? 有人以前有这个问题吗?

Turns out I was using the old this.props.activeRouteHandler() instead of <RouteHandler/> in my Application and Home components, which are the top level routes. 原来,我在Application和Home组件中使用了旧的this.props.activeRouteHandler()而不是<RouteHandler/> ,它们是顶级路由。 Doh. h

Correct syntax examples here http://rackt.github.io/react-router/ . 此处的正确语法示例http://rackt.github.io/react-router/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM