@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
55import clsx from 'clsx' ;
66import isEqual from 'lodash/isEqual' ;
77import fnToString from '../utils/fn-to-string' ;
8- import reducer , { flatOptions } from './reducer' ;
8+ import reducer , { init } from './reducer' ;
99import useIsMounted from '../hooks/use-is-mounted' ;
1010
1111const getSelectValue = ( stateValue , simpleValue , isMulti , allOptions ) => {
@@ -73,16 +73,11 @@ const Select = ({
7373 loadOptionsChangeCounter,
7474 SelectComponent,
7575 noValueUpdates,
76- useFlatOptions ,
76+ optionsTransformer ,
7777 ...props
7878} ) => {
79- const [ state , dispatch ] = useReducer ( reducer , {
80- isLoading : false ,
81- options : useFlatOptions ? flatOptions ( propsOptions ) : propsOptions ,
82- useFlatOptions,
83- promises : { } ,
84- isInitialLoaded : false ,
85- } ) ;
79+ const [ state , originalDispatch ] = useReducer ( reducer , { optionsTransformer, propsOptions } , init ) ;
80+ const dispatch = ( action ) => originalDispatch ( { ...action , optionsTransformer } ) ;
8681
8782 const isMounted = useIsMounted ( ) ;
8883
@@ -222,7 +217,7 @@ Select.propTypes = {
222217 isSearchable : PropTypes . bool ,
223218 SelectComponent : PropTypes . elementType . isRequired ,
224219 noValueUpdates : PropTypes . bool ,
225- useFlatOptions : PropTypes . bool ,
220+ optionsTransformer : PropTypes . func ,
226221} ;
227222
228223Select . defaultProps = {
0 commit comments