Skip to content
This repository was archived by the owner on Jun 12, 2026. It is now read-only.
This repository was archived by the owner on Jun 12, 2026. It is now read-only.

Perfomance inprovement for validity #19

Description

@EECOLOR

const { invalid } = useFormFieldSnapshot(field)

FormFieldValid is now implemented with useSnapshot which means it will render on keystrokes. We could add another hook that prevents these unneeded renders, something like this:

function useFormFieldInvalid(field) {
  const [formFieldInvalid, setFormFieldInvalid] = React.useState(() => snapshot.get(field).invalid)

  React.useEffect(
    () => {
      setFormFieldInvalid(snapshot.get(field).invalid)
      return snapshot.subscribe(field, x => setFormFieldInvalid(x.invalid))
    },
    [field]
  )

  return formFieldInvalid
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions