0.1.0 • Published 6 years ago

with-input v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

withInput

A lightweight, minimal react higher order component. That will generate state and handlers that will be passed down as props to the wrapped component.

Installation

Use npm or yarn.

yarn add with-input
npm i -s with-input

Api

withInput

asterik for mandatory props
ParamTypeDefaultDescription
name*stringkey for values on props
valuebooleanfalsedefault value
overridebooleanshould the auto generated handler be replaced with the passed handler
handlerFunctiona function that can act as a pre change hook or a function that will act as a handler and return the given state
Basic usage with strings
...
export default withInput('email', 'name')(ComponentName);
Basic usage with objects
...
export default withInput(
  {
    name: 'email',
    value: '',
  },
  {
    name: 'name',
    value: 'Jon',
  },
)(ComponentName);