@@ -6,13 +6,13 @@ import { convertChildrenToData } from '../utils/legacyUtil';
66 * Parse `children` to `options` if `options` is not provided.
77 * Then flatten the `options`.
88 */
9- export default function useOptions < OptionType > (
9+ const useOptions = < OptionType > (
1010 options : OptionType [ ] ,
1111 children : React . ReactNode ,
1212 fieldNames : FieldNames ,
1313 optionFilterProp : string ,
1414 optionLabelProp : string ,
15- ) {
15+ ) => {
1616 return React . useMemo ( ( ) => {
1717 let mergedOptions = options ;
1818 const childrenAsData = ! options ;
@@ -24,13 +24,17 @@ export default function useOptions<OptionType>(
2424 const valueOptions = new Map < RawValueType , OptionType > ( ) ;
2525 const labelOptions = new Map < React . ReactNode , OptionType > ( ) ;
2626
27- const setLabelOptions = ( labelOptionsMap , option , key ) => {
27+ const setLabelOptions = (
28+ labelOptionsMap : Map < React . ReactNode , OptionType > ,
29+ option : OptionType ,
30+ key : string | number ,
31+ ) => {
2832 if ( key && typeof key === 'string' ) {
2933 labelOptionsMap . set ( option [ key ] , option ) ;
3034 }
3135 } ;
3236
33- function dig ( optionList : OptionType [ ] , isChildren = false ) {
37+ const dig = ( optionList : OptionType [ ] , isChildren = false ) => {
3438 // for loop to speed up collection speed
3539 for ( let i = 0 ; i < optionList . length ; i += 1 ) {
3640 const option = optionList [ i ] ;
@@ -44,7 +48,8 @@ export default function useOptions<OptionType>(
4448 dig ( option [ fieldNames . options ] , true ) ;
4549 }
4650 }
47- }
51+ } ;
52+
4853 dig ( mergedOptions ) ;
4954
5055 return {
@@ -53,4 +58,6 @@ export default function useOptions<OptionType>(
5358 labelOptions,
5459 } ;
5560 } , [ options , children , fieldNames , optionFilterProp , optionLabelProp ] ) ;
56- }
61+ } ;
62+
63+ export default useOptions ;
0 commit comments