diff --git a/packages/react-select-async-paginate/CHANGELOG.md b/packages/react-select-async-paginate/CHANGELOG.md index e5797ff..202022f 100644 --- a/packages/react-select-async-paginate/CHANGELOG.md +++ b/packages/react-select-async-paginate/CHANGELOG.md @@ -4,6 +4,10 @@ - Fixed types import in modern environments [#150](https://github.com/vtaits/react-select-async-paginate/issues/150) +## Improvement + +- Migrate `defaultProps` to default arguments [#147](https://github.com/vtaits/react-select-async-paginate/issues/147) + ## 0.7.2 (14 dec 2022) # Bugfix diff --git a/packages/react-select-async-paginate/src/withAsyncPaginate.tsx b/packages/react-select-async-paginate/src/withAsyncPaginate.tsx index 2733e2b..d7b5b3a 100644 --- a/packages/react-select-async-paginate/src/withAsyncPaginate.tsx +++ b/packages/react-select-async-paginate/src/withAsyncPaginate.tsx @@ -21,6 +21,9 @@ import type { WithAsyncPaginateType, } from './types'; +const defaultCacheUniqs: unknown[] = []; +const defaultComponents = {}; + type SelectComponentType = < Option = unknown, IsMulti extends boolean = boolean, @@ -40,10 +43,10 @@ export function withAsyncPaginate( IsMulti extends boolean = false, >(props: AsyncPaginateProps): ReactElement { const { - components, - selectRef, + components = defaultComponents, + selectRef = undefined, isLoading: isLoadingProp, - cacheUniqs, + cacheUniqs = defaultCacheUniqs, ...rest } = props; @@ -69,11 +72,5 @@ export function withAsyncPaginate( ); } - WithAsyncPaginate.defaultProps = { - selectRef: null, - cacheUniqs: [], - components: {}, - }; - return WithAsyncPaginate; } diff --git a/packages/react-select-fetch/CHANGELOG.md b/packages/react-select-fetch/CHANGELOG.md index 3ff9768..c77cdb5 100644 --- a/packages/react-select-fetch/CHANGELOG.md +++ b/packages/react-select-fetch/CHANGELOG.md @@ -4,6 +4,10 @@ - Fixed types import in modern environments [#150](https://github.com/vtaits/react-select-async-paginate/issues/150) +## Improvement + +- Migrate `defaultProps` to default arguments [#147](https://github.com/vtaits/react-select-async-paginate/issues/147) + ## 0.5.0 (06 oct 2022) - Improved typing diff --git a/packages/react-select-fetch/src/withSelectFetch.tsx b/packages/react-select-fetch/src/withSelectFetch.tsx index 95eb3bd..173c7b7 100644 --- a/packages/react-select-fetch/src/withSelectFetch.tsx +++ b/packages/react-select-fetch/src/withSelectFetch.tsx @@ -25,6 +25,9 @@ import type { SelectFetchType, } from './types'; +const defaultCacheUniqs: unknown[] = []; +const defaultComponents = {}; + type SelectComponentType = < Option = unknown, IsMulti extends boolean = boolean, @@ -43,9 +46,9 @@ export function withSelectFetch( IsMulti extends boolean = false, >(props: SelectFetchProps): ReactElement { const { - components, - selectRef, - cacheUniqs, + components = defaultComponents, + selectRef = undefined, + cacheUniqs = defaultCacheUniqs, ...rest } = props; @@ -66,11 +69,5 @@ export function withSelectFetch( ); } - WithSelectFetch.defaultProps = { - selectRef: null, - cacheUniqs: [], - components: {}, - }; - return WithSelectFetch; }