API Reference > ui-core > Utilities > useOptionalDisposable useOptionalDisposable Function A custom hook which calls the factory method to create a disposable object which might as well be undefined. If the result was a disposable object, the hook takes care of disposing it when necessary. useOptionalDisposable<TDisposable extends IDisposable>(createDisposable: () => undefined | TDisposable): TDisposable | undefined Parameter Type Description createDisposable () => undefined | TDisposable Returns - TDisposable | undefined Defined in ui/core/src/ui-core/utils/hooks/useDisposable.ts Line 27 Last Updated: 11 June, 2024