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

时间:2015-02-06 15:14:37

标签: javascript reactjs react-router

我一直在尝试在我的一个应用程序中使用react路由器。但是我得到了

Uncaught TypeError: Cannot read property 'createClass' of undefined

在线

var DefaultRoute = React.createClass({ ..

我写的代码是

var Q                       = require('q'), 
    doThis                  = require('./generic/modules/doThis.js'),
    doThat                  = require('./generic/modules/doThat.js');
var React = require('react');
var Router = require('react-router');
var Route = Router.Route;
var Redirect = Router.Redirect;
var DefaultRoute = Router.DefaultRoute;

var aModule = require('./modules/aModule/aModule.js');
var Master = require('./modules/master/master.js');

var injectTapEventPlugin = require('react-tap-event-plugin');

(function (){

    var routes = (
        <Route name="root" path="/" handler={Master}>
            <Route name="time" handler={aModule} />
        </Route>);
    window.React = React;
    injectTapEventPlugin();

    var doThisPromise = doThis.init();
    doThisPromise.
    then(function() {
        doThat.init();
        Router.run (routes, function(Handler) {
            console.log('in router run');
            React.render(<Handler/>, document.body);
        });
    }, function (err) {

    });
})();

如有需要请询问,我也会提供与路线相关的js

- 编辑 - 构建文件中的相关错误代码

},{}],84:[function(require,module,exports){
var React = (window.React);
var FakeNode = require('../mixins/FakeNode');
var PropTypes = require('../utils/PropTypes');

/**
 * A <DefaultRoute> component is a special kind of <Route> that
 * renders when its parent matches but none of its siblings do.
 * Only one such route may be used at any given level in the
 * route hierarchy.
 */

var DefaultRoute = React.createClass({

  displayName: 'DefaultRoute',

  mixins: [ FakeNode ],

  propTypes: {
    name: React.PropTypes.string,
    path: PropTypes.falsy,
    handler: React.PropTypes.func.isRequired
  }

});

module.exports = DefaultRoute;

0 个答案:

没有答案