How to use the react-final-form.useFormState function in react-final-form

To help you get started, we’ve selected a few react-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 urbit / bridge / src / form / SubmitButton.js View on Github external
as: As = ForwardButton,
  className,
  children,
  handleSubmit,
  ...rest
}) {
  const {
    valid,
    validating,
    submitting,
    hasValidationErrors,
    hasSubmitErrors,
    dirtySinceLastSubmit,
    submitErrors,
    submitSucceeded,
  } = useFormState();

  const onlyWarningInSubmitErrors = onlyHasWarning(submitErrors);

  // can submit if:
  // 1) is valid
  //      OR has submit errors
  //      AND
  //        a) is dirty
  //        b) OR only has a warning (double conf)
  // 2) AND is not validating
  // 3) AND has no validation errors
  // 4) AND is not actively submitting
  // 5) AND submit has not yet succeeded
  const canSubmit =
    (valid ||
      (hasSubmitErrors &&
github sony / nmos-js / Development / src / components / ConnectionEditToolbar.js View on Github external
const ConnectionEditToolbar = ({ handleSubmitWithRedirect }) => {
    const formState = useFormState().values;
    const buttonProps = (() => {
        if (get(formState, '$staged.activation.activation_time')) {
            return [
                'Cancel Scheduled Activation',
                ,
            ];
        }
        switch (get(formState, '$staged.activation.mode')) {
            case 'activate_immediate':
                return ['Activate', ];
            case 'activate_scheduled_relative':
            case 'activate_scheduled_absolute':
                return ['Activate Scheduled', ];
            default:
                return ['Stage', ];
        }
github urbit / bridge / src / form / FormError.js View on Github external
export default function FormError(props) {
  const {
    submitError,
    submitErrors,
    error: validationError,
    dirtySinceLastSubmit,
  } = useFormState({
    subscription: {
      submitError: true,
      submitErrors: true,
      error: true,
      dirtySinceLastSubmit: true,
    },
  });

  const showValidationError = !!validationError;

  const showSubmitError = !!submitError && !dirtySinceLastSubmit;

  const warning = submitErrors && submitErrors[WARNING];
  const showWarning = !!warning && !dirtySinceLastSubmit;

  return showSubmitError || showValidationError || showWarning ? (
github marmelab / react-admin / examples / simple / src / posts / PostCreate.js View on Github external
const SaveWithNoteButton = props => {
    const [create] = useCreate('posts');
    const redirectTo = useRedirect();
    const notify = useNotify();
    const { basePath, redirect } = props;

    const formState = useFormState();
    const handleClick = useCallback(() => {
        if (!formState.valid) {
            return;
        }

        create(
            null,
            {
                data: { ...formState.values, average_note: 10 },
            },
            {
                onSuccess: ({ data: newRecord }) => {
                    notify('ra.notification.created', 'info', {
                        smart_count: 1,
                    });
                    redirectTo(redirect, basePath, newRecord.id, newRecord);

react-final-form

🏁 High performance subscription-based form state management for React

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages