import { useCallback , useMemo , useState } from 'react' ; import { FeatureCode } from '../containers/features/FeaturesContext' ; import useFeature from './useFeature' ; const useSpotlightOnFeature = ( code , initialShow = true ) => { const [ manualClose , setManualClose ] = useState ( false ) ; const { feature , update , loading } = useFeature ( code ) ; const show = useMemo ( ( ) => { return initialShow && ! loading && ! ! feature ?. Value && ! manualClose ; } , [ initialShow , loading , manualClose ] ) ; const onDisplayed = useCallback ( ( ) => { void update ( false ) ; } , [ ] ) ; const onClose = ( ) => setManualClose ( true ) ; return { show , onDisplayed , onClose } ; } ; export default useSpotlightOnFeature ;