UNPKG

ultradom-redux

Version:

Ultradom bindings for Redux

49 lines (39 loc) 1.09 kB
# ultradom-redux Ultradom bindings for Redux. Interface: `connect(mergeStateAndProps, options)` * `mergeStateAndProps` {Function} - merge store state and props that came from the top * `options` {Object} - options object * `options.connectRootTag` {String} - tag name of element outside of connected component * `options.componentRootTag` {String} - tag name of root element inside connected component Defaults: ```js connect( (state, ownProps) => ({ ...ownProps, ...state }), { connectRootTag: 'div', componentRootTag: 'div' } ) ``` Example: ```js function App(props) { return ( <div> <button onclick={ props.actions.click() }>Click</button> </div> ); } // Variables and functions: // actions - action creators // store - redux store // bindActionCreators - redux helper const AppConnected = connect((state, props) => ({ ...state, ...props, actions: bindActionCreators(actions, props.store.dispatch) }))(App) // Attach component to DOM // path - ultradom function path(<AppConnectd store={store} />, document.getElementById('app')) ```