UNPKG

mobx-react-lite

Version:

Lightweight React bindings for MobX based on React 16.8 and Hooks

14 lines (13 loc) 719 B
declare type TDisposable = () => void; /** * Adds an observable effect (reaction, autorun, or anything else that returns a disposer) that will be registered upon component creation and disposed upon unmounting. * Returns the generated disposer for early disposal. * * @export * @template D * @param {() => D} disposerGenerator A function that returns the disposer of the wanted effect. * @param {ReadonlyArray<any>} [inputs=[]] If you want the effect to be automatically re-created when some variable(s) are changed then pass them in this array. * @returns {D} */ export declare function useDisposable<D extends TDisposable>(disposerGenerator: () => D, inputs?: ReadonlyArray<any>): D; export {};