import { useEffect } from "react" ; import { OptionsType } from "./constants" ; export interface statusType { aborted ? : boolean ; } export const useAbortableEffect = ( effect , dependencies ) => { const status = { } ; useEffect ( ( ) => { status . aborted = false ; const cleanUpFn = effect ( status ) ; return ( ) => { status . aborted = true ; if ( typeof cleanUpFn === "function" ) { cleanUpFn ( ) ; } } ; } , [ ... dependencies ] ) ; } ; export const parseOptionId = ( options , id ) => { const textArray = options . filter ( ( option ) => { return id instanceof Array ? id . map ( ( i ) => String ( i ) ) . includes ( String ( option . id ) ) : String ( option . id ) === String ( id ) ; } ) . map ( ( option ) => option . text ) ; return textArray . join ( ", " ) ; } ;