Skip to content

Releases: andyrichardson/fielder

v2.2.0

12 Sep 15:54
821116c
Compare
Choose a tag to compare

v2.2.0 (2022-09-12)

Full Changelog

Additions:

  • Add support for persisting state #12

Merged pull requests:

v2.1.1

02 Nov 10:13
e3208c9
Compare
Choose a tag to compare

2.1.1 (2021-11-02)

Full Changelog

Closed issues:

  • useLayoutEffect warning when server side rendering #317

Merged pull requests:

v2.1.0

13 Jan 11:15
Compare
Choose a tag to compare

2.1.0 (2021-01-13)

Full Changelog

Additions:

  • Add preact support #299

Merged pull requests:

v2.0.0

22 Dec 15:15
Compare
Choose a tag to compare

v2.0.0 (2020-12-22)

Full Changelog

A new major release!

That's right, a new major release jam packed full of new features and with a side helping of breaking changes.

See the announcement post.

New docs site

Technically not part of this release but definitely worth a visit to check out the new guides!

Visit the docs!

Event driven validation

Validation is now tailored to specific events (mount, blur, submit, etc).

This provides extra flexibility to tweak validation for specific scenarios - such as triggering async validation only on submit (see example below).

useField({
  validate: useCallback(({ trigger, value  }) {
    // Validation for all events
    if (!value) {
      throw Error("Value is required.");
    }

    // Validation for blur only events
    if (trigger == "blur" && value.length < 4) {
      throw Error("Value must be at least 4 characters.");
    }

    // Async validation only on submit
    if (trigger == "submit") {
      return serverSideValidation(value).then((isValid) => {
        if (!isValid) {
          throw Error("Server side validation failed");
        }
      });
    }
  }, [])
})

More info on event driven validation can be found here.

useSubmit hook

There's a new useSubmit hook which:

  • triggers the new submit validation event
  • aggregates field values into a single object
  • tracks state of async submission validation
  • guards submission logic until validation succeeds
const { isValidating, hasSubmitted, handleSubmit } = useSubmit(() => {
  console.log('This is only called if submission validation succeeds!');
});

handleSubmit(); // Trigger submission

More info on submission can be found here.

Breaking changes

  • initialValue argument on the useField hook is now required (more info)
  • validate argument on the useField hook now receives only a single argument (more info)
  • removed deprecated properties touched and initalTouched on the useField hook (more info)
  • removed initialValid and initialError arguments on the useField hook in favor of validation events (more info)
  • removed validateOnBlur, validateOnChange, and validateOnUpdate arguments on the useField hook in favor of validation events (more info)
  • removed support for returning validation errors as strings without throwing (more info)

v1.3.1

30 Jul 09:39
Compare
Choose a tag to compare

v1.3.1 (2020-07-30)

Full Changelog

Fixed bugs:

  • Changes to validation arg doesn't update validation function #235

Merged pull requests:

v1.3.0

14 Jun 14:35
Compare
Choose a tag to compare

v1.3.0 (2020-06-14)

Full Changelog

Additions:

  • Add support for providing value to onChange #41
  • Add support for React Native #35
  • Add non DOM event support to onChange #123 (andyrichardson)

Closed issues:

  • Add sitemap to docs #49
  • Update branching example to use consistent theming #47

Merged pull requests:

v1.2.1

25 Feb 01:34
Compare
Choose a tag to compare

v1.2.1 (2020-02-25)

Full Changelog

Fixed bugs:

Closed issues:

  • Add docs for branching #26

Merged pull requests:

v1.2.0

05 Feb 18:27
Compare
Choose a tag to compare

v1.2.0 (2020-02-05)

Full Changelog

Breaking changes:

Additions:

  • Add tracking of 'hasChanged' and 'hasBlurred' states #21

Merged pull requests:

v1.1.2

21 Jan 18:39
Compare
Choose a tag to compare

v1.1.2 (2020-01-21)

Full Changelog

Fixed bugs:

  • Fix initial value for radio inputs #30
  • Fix initial value for checkbox inputs #28
  • Textarea onChange error #24

Closed issues:

  • Add examples for validation and conditional rendering #33
  • Add documentation for checkbox inputs #23
  • Explain how to handle submission of field values #22

Merged pull requests:

v1.1.1

10 Jan 17:28
Compare
Choose a tag to compare

v1.1.1 (2020-01-10)

Full Changelog

Fixed bugs:

  • Handle destroy on unmount changing value #18

Merged pull requests: