0

単純な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"
  },
4

1 に答える 1