我确定我在这里遗漏了一些简单的东西,但无法正确配置我的路线。
我收到此错误:
Warning: Failed prop type: The prop 'children' is marked as required in 'App', but its value is 'undefined'.
in App (created by RouterContext)
in RouterContext (created by Router)
in Router
这是我的基本设置:
./index.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import {Router, browserHistory} from 'react-router';
import routes from './routes';
ReactDOM.render(
<Router history={browserHistory} routes={routes}/>, document.getElementById('root'));
./routes/index.js
module.exports = {
path: '/',
component: require('../components/app'),
indexRoute: require('./home')
};
./routes/home.js
module.exports = {
getComponent(nextState, cb) {
require.ensure([], (require) => {
cb(null, require('../components/home'));
});
}
};
./components/app/index.jsx
import React, {PropTypes} from 'react';
const App = props => (
<section>
<h1>My App</h1>
<section>{props.children}</section>
</section>
);
App.propTypes = {
children: PropTypes.node.isRequired
};
export default App;
./components/home/index.jsx
import React from 'react';
const Home = () => (
<section>
<h3>Home</h3>
</section>
);
export default Home;