@gechiui/compose
Version:
GeChiUI higher-order components (HOCs).
20 lines • 917 B
TypeScript
import type { ComponentType } from 'react';
/**
* We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`
* types here because those functions include functionality that is not handled
* by this component, like the ability to pass extra arguments.
*
* In the case of this component, we only handle the simplest case where
* `setTimeout` only accepts a function (not a string) and an optional delay.
*/
declare type TimeoutProps = {
setTimeout: (fn: () => void, delay: number) => number;
clearTimeout: (id: number) => void;
};
/**
* A higher-order component used to provide and manage delayed function calls
* that ought to be bound to a component's lifecycle.
*/
declare const withSafeTimeout: <InnerProps extends TimeoutProps>(Inner: ComponentType<InnerProps>) => ComponentType<Omit<InnerProps, keyof TimeoutProps>>;
export default withSafeTimeout;
//# sourceMappingURL=index.d.ts.map