react-select@4.0.0
Upgrade Guide
Summary
- Standardize value passed to
onChange(#4339) - theonChangehandler is now always passed an array of options ifisMultiis set totrue - Emotion 11 (#4283) - should only affect you if you're using the
NonceProvidercomponent - 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
-
02050675 #4339 Thanks @Methuselah96! - Standardized value passed to onChange
-
26b6325c #4283 Thanks @majgaard! - Upgrades Emotion dependency to v11.0.0
BREAKING CHANGE: The NonceProvider component now requires a
cacheKeyprop that corresponds to thekeyfor the Emotion cache. -
b2488bb5 #4313 Thanks @Methuselah96! - Removed usages of UNSAFE React methods
Patch Changes
- 2d5496d5 #4388 Thanks @Methuselah96! - Removed memoization of buildMenuOptions