react-with-state
v1.0.0
Published
react-with-state React component
Downloads
2
Readme
react-with-state
Higher-order component abstraction for adding state management to a dumb component.
provides these props:
- state
- setState
import React from 'react'
import {render} from 'react-dom'
import withState from '../../src'
const Counter = ({state, setState}) =>
<div>
{state.count}
<button onClick={() => setState({count: state.count + 1})}>
Increment
</button>
</div>
const manageCounterState = withState({count: 0})
const ManagedCounter = manageCounterState(Counter)
render(<ManagedCounter />, document.querySelector('#demo'))