ultradom-redux
v1.0.0
Published
Ultradom bindings for Redux
Downloads
8
Readme
ultradom-redux
Ultradom bindings for Redux.
Interface:
connect(mergeStateAndProps, options)
mergeStateAndProps
{Function} - merge store state and props that came from the topoptions
{Object} - options objectoptions.connectRootTag
{String} - tag name of element outside of connected componentoptions.componentRootTag
{String} - tag name of root element inside connected component
Defaults:
connect(
(state, ownProps) => ({
...ownProps,
...state
}),
{
connectRootTag: 'div',
componentRootTag: 'div'
}
)
Example:
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'))