Usage with React
We will use React to build our simple app, and cover the basics of how to use React with event-flux
.
Installing React event-flux
React bindings are not included in event-flux
by default. You need to install them explicitly:
Basic Example
First we create CounterStore to handle counter state.
Then we create AppStore instance with declaring CounterStore
and pass this AppStore instance to Provider.
Now we can inject some stores and states to Counter component. For withEventFlux(eventFluxArgs)
, The key of eventFluxArgs
is the store key that will be injected, so counterStore
will be loaded. The value of eventFluxArgs
is state filter that stand for what shape of state can be injected. The ["counter"]
filter represent that counterStore's counter
state will be injected and other states in counterStore
will be ignored.
Last updated
Was this helpful?