让反应路由器工作

时间:2016-05-29 18:49:44

标签: reactjs react-router

尝试让最基本的路由工作

var Router = ReactRouter;
var DefaultRoute = Router.DefaultRoute;
var Link = Router.Link;
var Route = Router.Route;
var RouteHandler = Router.RouteHandler;



    var Hello = React.createClass({
        render: function() {
            return <div> 
            <h1> Hello at {this.props.now} </h1>
                              <RouteHandler />

            </div>
        }

    });


    ReactDOM.render(<Hello now = { new Date().toString()} />, 
        document.getElementById('outer-container'));

        var routes = (
    <Route name="app" path="/" handler={Hello}>

    </Route>
);

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

但是我收到以下错误

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Hello`.

我缺少什么

0 个答案:

没有答案