The high order component for creating uncontrolled component
npm install @rcp/hoc.uncontrolled
# or use yarn
yarn add @rcp/hoc.uncontrolled
import uncontrolled from '@rcp/hoc.uncontrolled'
// `props.defaultValue` and `props.value`
// could be assigned to `this.state.value` in `constructor` and `componentWillReceiveProps` automatically.
@uncontrolled(['value'])
class Input extends React.Component {
render() {
return <input value={this.state.value} />
}
}
propList
{Prop[]} eg.['value']
/[{ name: 'value', withDefault: false, eq: (a, b) => a === b }]
Returns Function (Component: React.ComponentClass) => React.ComponentClass
This library is written and maintained by imcuttle, mailto:moyuyc95@gmail.com.
MIT