Created
July 19, 2019 12:12
-
-
Save kasper573/f85da313e9fedd135edd899d5a7ebe58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { EffectCallback, useEffect } from 'react'; | |
export const usePureEffect = <T extends EffectCallbackWithParams>( | |
effect: T, | |
...params: Parameters<T> | |
) => useEffect(() => effect.apply(null, params), params); | |
type EffectCallbackWithParams = (...args: any) => ReturnType<EffectCallback>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment