我有一个简单的redux样板项目,当我导入顶级(智能)组件时,与内联类声明相比,我遇到了不同的行为。
创建类不会导致错误,但是当我将类提取到单独的文件时,我收到以下错误:
Warning: Failed propType: Required prop `routerState` was not specified in `AppContainer`. Check the render method of `RoutingContext`.
我已经尝试内联整个文件并且错误消失了
// == Import ==================================================================
import AppContainer from '../containers/App.jsx';
// === Declare Inline =========================================================
import { connect } from 'react-redux';
import { Component, PropTypes } from 'react';
@connect(state => ({ routerState: state.router }))
class AppContainer extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
routerState: PropTypes.object.isRequired,
}
render() {
return (
<div className="container-fluid">
<div className="row">
<div className="col-xs-12">
<h1>App</h1>
{this.props.children}
</div>
</div>
</div>
);
}
}
// ============================================================================
这是项目回购(它的超级条纹背)。
"dependencies": {
"history": "^1.12.5",
"react": "^0.14.0",
"react-dom": "^0.14.0",
"react-redux": "^4.0.0",
"react-router": "^1.0.0-rc3",
"redux": "^3.0.2",
"redux-router": "^1.0.0-beta3"
},