This higher-order component is used to create components that can be used with inputProps
from connectWithInputs.
InputComponent
(Component)options
(Object)-
onChangeTransform
(Function) [optional] Turn a browser change event into a value. (e.g.e => e.target.value
forinput
)
id
(string): unique id for this input, can be used to link label and inputvalue
(any): represents the current value as defined by the input's stateerror
(boolean): True if the current value is invaliderrorText
(string)onChange
(function): Takes one parameter - the new valuevalidating
(boolean): True while async validation is in progresspristine
(boolean): True if the input hasn't been touched or set by anything other than defaultValue or initialization
parser(value:Any)
(function) transforms the new value before validating and updatingformatter(value:Any)
(function) transforms the stored value before passing to the componentonValidationSuccess(inputs:Object)
(function) callback after successful change - same as resolve of updateAndValidateinputs
(Object) object of changed input(s)
onValidationFail(inputs:Object)
(function) callback after failed validation - same as reject of updateAndValidateinputs
(Object) object of changed input(s)
The ReduxInputsWrapper
looks at the input and turns it into value
, and error
props, where value
is equal to
inputs.email.value
if inputs.email.error
is undefined, or inputs.email.error
otherwise. The ReduxInputsWrapper
passes down any other properties of the input state untouched, with the exception of onChange
which will be called
after redux-inputs changes are dispatched.
Then this input can be used in the render of connected YourForm
like this:
render() {
const { inputProps } = this.props.reduxInputs;
return (
<Input {...inputProps.email}/>
);
}
Changes from this input will be validated and dispatched, then passed back through component update.