import React, { useEffect, useState } from 'react'; import Select from '@educt/components/Select'; import { ISelectPropsType } from '../Select/Select'; import { OptionType } from '@educt/types'; interface IAsyncSelectPropsType extends ISelectPropsType { loadOptions: () => Promise; } const AsyncSelect: React.FC = props => { const [options, setOptions] = useState([]); const [isLoading, setIsLoading] = useState(false); const { loadOptions, ...selectProps } = props; useEffect(() => { setIsLoading(true); loadOptions() .then(options => options && setOptions(options)) .finally(() => setIsLoading(false)); }, []); return