React Deflux
Yet another flux implementation, with bindings for react. Built over react's new context API.
Getting Started
Wrap ReState over your root component.
; <ReState store=initialState // initial state of your store applyMiddleWare=fetchDataMiddleWare // Optional, Allows managing side-effects> <App /></ReState>
That's it, now any child component can connect to store.
; const App = <div> <button onClick=buttonClick > Fire Action! </button> </div>; const mapStateToProps = ...state const mapDispatchToProps = mapStateToProps mapDispatchToPropsApp
Middleware
This the best part. You can pass any function (middleware) to the applyMiddleWare prop, and it will be fired with every action.
// Handling async with middleware actiontype === 'FETCH_DATA' &&