How to use the final-form.setIn function in final-form

To help you get started, we’ve selected a few final-form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / lunar / packages / forms / src / components / Form / index.tsx View on Github external
const value = typeof initial === 'undefined' ? config.defaultValue : initial;

    if (!field) {
      return;
    }

    field.data.config = config;
    // @ts-ignore
    field.initial = value;
    // @ts-ignore
    field.value = value;
    field.touched = config.validateDefaultValue || false;

    // These are needed for form "reset" to work correctly!
    /* eslint-disable no-param-reassign */
    formState.initialValues = setIn(formState.initialValues!, name, value);
    formState.values = setIn(formState.values, name, value);
    /* eslint-enable no-param-reassign */
  }
github airbnb / lunar / packages / forms / src / components / Form / index.tsx View on Github external
if (!fieldData || !fieldData.config) {
        return data;
      }

      // Type cast the value
      if (fieldData.config.parse) {
        value = this.castValue(value, fieldData.config.parse);
      }

      // Trim the value
      if (typeof value === 'string') {
        value = value.trim();
      }

      return setIn(data, name, value);
    }, initialData) as Data;
  }
github airbnb / lunar / packages / forms / src / components / Form / index.tsx View on Github external
if (!field) {
      return;
    }

    field.data.config = config;
    // @ts-ignore
    field.initial = value;
    // @ts-ignore
    field.value = value;
    field.touched = config.validateDefaultValue || false;

    // These are needed for form "reset" to work correctly!
    /* eslint-disable no-param-reassign */
    formState.initialValues = setIn(formState.initialValues!, name, value);
    formState.values = setIn(formState.values, name, value);
    /* eslint-enable no-param-reassign */
  }
github airbnb / lunar / packages / forms / src / components / Form / index.tsx View on Github external
fields.map(async field => {
        if (!field) return;

        const { name, data: fieldData } = field;

        if (fieldData && fieldData.config && fieldData.config.validator) {
          const value = getIn(data, name);

          if (typeof value !== 'undefined') {
            try {
              await fieldData.config.validator(value, data);
            } catch (error) {
              errors = setIn(errors, name, error.message);
            }
          }
        }
      }),
    );

final-form

🏁 Framework agnostic, high performance, subscription-based form state management

MIT
Latest version published 7 months ago

Package Health Score

71 / 100
Full package analysis