local-state-hoc
v1.0.3
Published
``` import {connect} from 'react-redux' import {withLocalState} from 'local-state-hoc'
Downloads
3
Readme
Local State Hoc
import {connect} from 'react-redux'
import {withLocalState} from 'local-state-hoc'
const View = ({ updateIndex, index }) => (
<div>
<button onClick={updateIndex} />
<p>{index}</p>
</div>
)
const defaultLocalState = {
index: 0
}
const mapStateToProps = (_, { localState, setLocalState }) => ({
updateIndex: () => setLocalState({ index: localState.index + 1 }),
index: localState.index
})
export default withLocalState(connect(mapStateToProps)(View), defaultLocalState)