diff --git a/.changeset/metal-pens-boil.md b/.changeset/metal-pens-boil.md new file mode 100644 index 0000000000..47b1fa5bbe --- /dev/null +++ b/.changeset/metal-pens-boil.md @@ -0,0 +1,5 @@ +--- +'react-select': patch +--- + +Resolve `defaultProps` deprecation warning for React v18+. diff --git a/packages/react-select/src/components/Menu.tsx b/packages/react-select/src/components/Menu.tsx index d5cc0a79ad..7483fa045e 100644 --- a/packages/react-select/src/components/Menu.tsx +++ b/packages/react-select/src/components/Menu.tsx @@ -498,49 +498,53 @@ export const NoOptionsMessage = < Option, IsMulti extends boolean, Group extends GroupBase ->( - props: NoticeProps -) => { - const { children, innerProps } = props; +>({ + children = 'No options', + innerProps, + ...restProps +}: NoticeProps) => { return ( {children} ); }; -NoOptionsMessage.defaultProps = { - children: 'No options', -}; export const LoadingMessage = < Option, IsMulti extends boolean, Group extends GroupBase ->( - props: NoticeProps -) => { - const { children, innerProps } = props; +>({ + children = 'Loading...', + innerProps, + ...restProps +}: NoticeProps) => { return ( {children} ); }; -LoadingMessage.defaultProps = { - children: 'Loading...', -}; // ============================== // Menu Portal diff --git a/packages/react-select/src/components/indicators.tsx b/packages/react-select/src/components/indicators.tsx index 052cc13c90..51a2ecec28 100644 --- a/packages/react-select/src/components/indicators.tsx +++ b/packages/react-select/src/components/indicators.tsx @@ -287,17 +287,22 @@ export const LoadingIndicator = < Option, IsMulti extends boolean, Group extends GroupBase ->( - props: LoadingIndicatorProps -) => { - const { innerProps, isRtl } = props; - +>({ + innerProps, + isRtl, + size = 4, + ...restProps +}: LoadingIndicatorProps) => { return ( @@ -306,4 +311,3 @@ export const LoadingIndicator = < ); }; -LoadingIndicator.defaultProps = { size: 4 };