reactjs flux - Should view call the store directly? -
reactjs flux - Should view call the store directly? -
from flux's todomvc example, saw todoapp component asking store states.
should view create action , allow dispatcher phone call store instead?
the views listening stores' "change" event called controller-views, because have 1 controller-like aspect: whenever stores change, info stores , pass children through props.
the controller-views views should calling stores' getters. getters should public api stores expose. stores have no setters.
it's tempting phone call stores' getters within render()
method of component deep in tree, anti-pattern. violates unidirectional info flow, making more hard understand flow of info through application, , , makes rendering more expensive.
in todomvc flux example, todoapp component controller-view.
reactjs-flux flux
Comments
Post a Comment