local-state-hoc

1.0.3 • Public • Published

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)

Readme

Keywords

none

Package Sidebar

Install

npm i local-state-hoc

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

74.1 kB

Total Files

6

Last publish

Collaborators

  • jtparrett