我有一個簡單的redux樣板項目,當我導入頂級(智能)組件時,與我內聯類聲明相比,我遇到了不同的行爲。在聲明內聯導入時使用相同的JSX組件時出錯
創建類導致沒有錯誤但是當我解壓類到一個單獨的文件,我收到以下錯誤:
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>
);
}
}
// ============================================================================
這是project repo(它的超級條紋背)。
"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"
},
很奇怪,我會拉下回你的回購,看看 – JonE