私はこのような「createFunctional」フラックスコンテナ機能を使用するフラックスパターンを持ってプロジェクトに取り組んでいます:フラックスコンテナ関数 'createFunctional'の目的は何ですか?
import {Container} from 'flux/utils';
import View from './MyView.js';
import AppStore from './AppStore.js';
function getStores() {
return [
AppStore
];
}
function getState() {
var state = {
pie: AppStore.getState(),
};
return state;
}
export default Container.createFunctional(View, getStores, getState);
私はより良い、このコードを理解したいと思いますが、私はそれが難しいのドキュメントを見つけるために探していますこの関数。
私は何とかビューに格納し、状態機能を結合されている推測していて、それが何らかの形で(私はexample on the flux websiteに基づいて再構築している)、このコードと同じものです:
class MyView extends Component {
static getStores() {
return [AppStore];
}
static calculateState(prevState) {
return {
pie: AppStore.getState(),
};
}
render() {
return <div>blah..</div>;
}
}
const container = Container.create(CounterContainer);
私は以前は純粋なフラックスを使用していませんでしたが、ソースを調べてみると、これはreduxの 'connect'と似ています。私は店舗の変化を見て、変化があるときには、全体の状態を下位のコンポーネント(最初のパラメータ)に渡します。 – Sulthan