Skip to content

Releases: final-form/react-final-form

v6.0.1

29 May 20:39
v6.0.1
Compare
Choose a tag to compare

Bug Fixes

  • No rerender on validateFields change #504 #502

Type Fixes

  • Fix Flow typings for UseFieldConfig and FieldProps #503
  • Added back flow types that got removed #505 #500
  • Update Types to make useField's options optional #499

v6.0.0...v6.0.1

v6.0.0

27 May 10:13
v6.0.0
Compare
Choose a tag to compare

This release contains very minimal, edge-case, breaking changes.

Bug Fixes

  • Fixed bug in form component rerendering not responding to changes in form state properly. #498 #487 #492

⚠️ Breaking Changes ⚠️

  • Subscription changes will now be ignored. For some reason previous versions of React Final Form did extra work to allow you to change the subscription prop, causing the component to reregister with the Final Form instance. That is a very rare use case, and it was a lot of code to enable it. If you need to change your subscription prop, you should also change the key prop, which will force the component to be destroyed and remounted with the new subscription.
  • parse={null} and format={null} are no longer allowed. That was a bad choice of API design, which is probably why Flow doesn't allow the Function | null union type. #400 Passing null served the purpose of disabling the default parse and format functionality. If you need to disable the existing parse and format, you can pass an identity function, v => v, to parse and format.

< v6

<Field name="name" parse={null} format={null}/>

>= v6

const identity = v => v
...
<Field name="name" parse={identity} format={identity}/>

v5.1.2...v6.0.0

v5.1.2

24 May 09:49
v5.1.2
Compare
Choose a tag to compare
  • Converted to use React.FC df89fde
  • Added missing length value to FieldRenderProps 89454a4

v5.1.1...v5.1.2

v5.1.1

24 May 08:14
v5.1.1
Compare
Choose a tag to compare

Bug Fixes

  • Add state.change to useField's onChange dependencies. #477
  • Make flattenSubscription hooks-safe #479

Type Fixes

  • add beforeSubmit and afterSubmit to typescript def #484
  • Add simple test for generic FieldRenderProps type #439
  • Tweak useFormState TS types #482 #476
  • Adjust ts definitions #486

v5.1.0...v5.1.1

v5.1.0

16 May 11:23
v5.1.0
Compare
Choose a tag to compare

New Features

v5.0.2...v5.1.0

v5.0.2

15 May 17:08
v5.0.2
Compare
Choose a tag to compare

Bug Fixes

v5.0.1

15 May 10:31
v5.0.1
Compare
Choose a tag to compare

🤦‍♂️

  • Actually changed peerDep to React 16.8 99cef7d

v5.0.0...v5.0.1

v5.0.0

15 May 10:21
v5.0.0
Compare
Choose a tag to compare

🎉 v5.0.0 – HOOKS!!! 🎉

First to explain why this change was made... To manage subscriptions to the internal 🏁 Final Form instance, 🏁 React Final Form has been using some legacy lifecycle methods that make the side effect of subscribing to an event emitter cumbersome. Such subscriptions are a perfect use case (no pun intended) for the new React.useEffect() hook. In an effort to modernize and future proof the library, the entire thing has been rewritten to use hooks.

All the previous tests have been rewritten to use 🐐 React Testing Library, which is a superior way to test React components. None of the tests were removed, so all existing functionality from v4 should work in v5, including some optimizations to minimize superfluous additional renders that were made possible by hooks.

⚠️ BREAKING CHANGES 😮

Don't worry...there really aren't that many.

  • Requires ^react@16.8.0. That's where the hooks are. 🙄
  • All deprecated functions provided in FormRenderProps and FormSpyRenderProps have been removed. They have been spitting warnings at you since v3, so you've probably already corrected for this. The following applies to:
    • batch
    • blur
    • change
    • focus
    • initialize
    • mutators
    • reset

Rather than spreading the FormApi into the render props, you are just given form itself.

v4

<Form onSubmit={submit}>{({ reset }) => (
  // fields here
  <button type="button" onClick={reset}>Reset</button>
)}</Form>

v5

<Form onSubmit={submit}>{({ form }) => (
  // fields here
  <button type="button" onClick={form.reset}>Reset</button>
)}</Form>
  • Field will no longer rerender when the validate prop. Note: it will still always run the latest validation function you have given it, but it won't rerender when the prop is !==. This is to allow the very common practice of providing an inline => function as a field-level validation function. This change will break the very rare edge case where if you are swapping field-level validation functions with different behaviors on subsequent renders, the field will no longer rerender with the new validation errors. The fix for this is to also change the key prop on Field any time you swap the validate function. See this test for an example of what I mean. There's also a sandbox demonstrating the issue:

Edit Changing Field Level Validators

  • The previously exported withReactFinalForm HOC has been removed. Now you should use the useForm() hook if you'd like to get the 🏁 Final Form instance out of the context. To ease your transition, you can make your own with a single line of code:
const withReactFinalForm = Component => props =>
  <Component reactFinalForm={useForm()} {...props} /> 

😎 New Hook API 😎

Because it was so easy to do, 🏁 React Final Form now exports the useField and useFormState hooks that are used internally in Field and FormSpy respectively. Literally the only thing Field and FormSpy do now is call their hook and then figure out if you are trying to render with the component, render, or children prop.

For example, before v5, if you wanted to create a custom error component that only rerendered when touched or error changed for a field, you'd have to do this:

v4

const Error = ({ name }) => (
  <Field name={name} subscription={{ touched: true, error: true }}>
    {field =>
      field.meta.touched && field.meta.error ? (
        <span>{field.meta.error}</span>
      ) : null
    }
  </Field>
)

...but now you can do:

v5

const Error = ({ name }) => {
  const field = useField(name, { subscription: { touched: true, error: true } })
  return field.meta.touched && field.meta.error ? (
    <span>{field.meta.error}</span>
  ) : null
}

Not too groundbreakingly different, but these hooks might allow for some composability that was previously harder to do, like this clever disgusting hack to listen to multiple fields at once.

Go forth and hook all the things! 🎣


Special thanks to @Andarist for giving me such an extensive code review on #467.

v4.1.0

04 Mar 19:23
Compare
Choose a tag to compare

🎉 New Features 🎉 (requires final-form@4.12.0)

  • Two new props to Field: defaultValue and initialValue allow fine grain control over how your field values are initialized at the field level. #387
  • Added meta.modified flag for all fields. A field becomes modified the first time its value changes. Previously, with dirty, if the user returned the value to the initial value, the form state had no evidence that the value had ever changed. This is what modified provides.

Bug Fixes

  • Fixed displayName of context provider HOC #375

Type Fixes

  • Updated FieldProps.validate type definition #413
  • Add Typescript typings for third argument of validate function #429

Build Improvements

  • Externalized babel helpers using @babel/runtime #402
  • More selective on Travis node versions #386
  • Remove unused prop-types dependency #424
  • Better Typescript tests #418

v4.0.2

16 Nov 14:49
v4.0.2
Compare
Choose a tag to compare

Flow Fixes