Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 963 Bytes

Input.md

File metadata and controls

48 lines (36 loc) · 963 Bytes

Input

import { Input } from 'react-powerplug'
<Input>
  {({ value, set }) => (
    <ControlledInput value={value} onChange={e => set(e.target.value)} />
  )}
</Input>
<Input initial="hello world">
  {({ bind }) => <ControlledInput {...bind} />}
</Input>

Input Props

initial = '' (optional)
Specifies the initial value state.
By default, the initial count state is an empty string.

onChange (optional)
The onChange event of the Input is called whenever the value state changes.

Input Children Props

TL;DR: { value, set, bind }

value
any
Your value state

set
(value) => any
Set a new value. Can be a function that pass actual value as args. Ex.: set(value => value + 1)

bind
{ value: value, onChange: (event) => event.target.value }
Just add water™ object with onChange and value. So you can in a practical way bind your input.

<input {...bind} />