@comparaonline/ui-input-listener
TypeScript icon, indicating that this package has built-in type declarations

0.0.2-alpha.0 • Public • Published

Input Listener

Usage

The input listener actually renders a Field component from react-final-form with the same input name that the field that we want to change and uses the onChange function to update its value.

import { Form } from 'react-final-form';
import { TextField } from '@comparaonline/ui-form-fields';
import { InputListener } from '@comparaonline/ui-input-listener';

const onSubmit = () => undefined;

<Form onSubmit={onSubmit}>
  {({ handleSubmit }) => (
    <form onSubmit={handleSubmit}>
      <TextField
        name="inputA"
        label="Placa"
      />
      <TextField
        name="inputB"
        label="Placa"
      />
      <InputListener field="inputA" when={value => value === 'foo'} set="inputB" to={new Promise(resolve => resolve('new value'))} />
    </form>}
</Form>;

Readme

Keywords

none

Package Sidebar

Install

npm i @comparaonline/ui-input-listener

Weekly Downloads

7

Version

0.0.2-alpha.0

License

MIT

Unpacked Size

19.2 kB

Total Files

17

Last publish

Collaborators

  • suarezcumare
  • comparaonline-dev
  • comparaonlineprivate
  • gnavarro
  • matotias
  • smurua
  • eseceve
  • pablocompara
  • pfariaz
  • ricardo.sosa
  • dsuarez_compa
  • emartinicompara