github JedWatson/react-select react-select@4.0.0

latest releases: react-select@5.8.0, react-select@5.7.7, react-select@5.7.6...
3 years ago

Upgrade Guide

Summary

  • Standardize value passed to onChange (#4339) - the onChange handler is now always passed an array of options if isMulti is set to true
  • Emotion 11 (#4283) - should only affect you if you're using the NonceProvider component
  • Remove usage of UNSAFE React methods (#4313) - shouldn't affect you except now you won't see those warning messages in the console anymore

Details

Standardize value passed to onChange

This change makes it so that the first parameter passed to the onChange callback will now always be an array of options if isMulti is set to true and will always be a single option or null if isMulti is set to false. Previously the first parameter of onChange could be an array or null when isMulti was set to true.

That means if you were previously using nullish coalescing in order to handle null for isMulti:

<Select
  isMulti
  onChange={(newValues) =>  setValues(newValues ?? [])}
/>

You can now remove the nullish coalescing because onChange will always be an array when isMulti is set to true:

<Select
  isMulti
  onChange={(newValues) =>  setValues(newValues)}
/>

Emotion 11

The NonceProvider component now requires a cacheKey prop that corresponds to the newly required key prop for the Emotion cache. This won't affect you if you aren't using NonceProvider. See #4283 for more details.

Remove usage of UNSAFE React methods

This isn't necessarily a breaking change, but it required a large refactor in order to accomplish so we released this in a major upgrade in case it has some unintended consequences.

Changelog

Major Changes

Patch Changes

Don't miss a new react-select release

NewReleases is sending notifications on new releases.