News for hackers. Stuff that matters.
Re:Making SetInterval Declarative with React Hooks by underwater on Monday February 04, 2019 @03:35AM (#19074795)
The pattern of returning an unregister function is a common one. But I agree that the cache key array is strange.

I'd almost suggest that a seperate useEffectOnce function would be better, but I'm sure the abstraction was heavily tested and bikeshedded before it was released in this form.

Re:Making SetInterval Declarative with React Hooks by feralfoo on Tuesday February 05, 2019 @06:28AM (#19084366)
You could create userEffectOnce as a custom hook:

function useEffectOnce(callback) { useEffect(() => { return callback() }, []) }