bertho-zero / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using react, redux, express and feathers
https://react-hot-example.herokuapp.com/
MIT License
636 stars 171 forks source link

Update react-final-form to the latest version ๐Ÿš€ #542

Open greenkeeper[bot] opened 5 years ago

greenkeeper[bot] commented 5 years ago

The dependency react-final-form was updated from 4.1.0 to 5.0.0.

This version is not covered by your current version range.

If you donโ€™t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.


Release Notes for v5.0.0

๐ŸŽ‰ 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.

๐Ÿ˜Ž 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.

Commits

The new version differs by 14 commits.

  • 35b85b9 5.0.0
  • 376fc69 Removed deprecated api from docs
  • c851c78 Removed misguided hooks docs
  • ffd2003 Hooks!!! (#467)
  • 41d24d6 Added CLI example
  • 45d5e97 Fixed anchor for selective example
  • bfa390e Merge branch 'master' of github.com:final-form/react-final-form
  • 230c169 Upgraded deps and fixed vulnerabily with tar package
  • cb17dc5 Added selective debounce demo
  • e8138a3 Fix onChange TS type signature (#438)
  • 5f036e2 Update readme that warnings do not prevent submit (#447)
  • a3ca5f1 Fixed tslint errors
  • 6cc9b12 Unify TS tests & backport removed typing improvements (#435)
  • d68a91f v4.1.0

See the full diff

FAQ and help There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those donโ€™t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).

Your Greenkeeper bot :palm_tree:

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

Release Notes for v5.0.1

๐Ÿคฆโ€โ™‚๏ธ

  • Actually changed peerDep to React 16.8 99cef7d

v5.0.0...v5.0.1

Commits

The new version differs by 2 commits.

See the full diff

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 5 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 4 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 4 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 4 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 4 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 4 years ago

Update to this version instead ๐Ÿš€

greenkeeper[bot] commented 4 years ago

๐Ÿšจ Reminder! Less than one month left to migrate your repositories over to Snyk before Greenkeeper says goodbye on June 3rd! ๐Ÿ’œ ๐Ÿšš๐Ÿ’จ ๐Ÿ’š

Find out how to migrate to Snyk at greenkeeper.io


Update to this version instead ๐Ÿš€