|
|
|
|
|
by underwater
2689 days ago
|
|
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. |
|
function useEffectOnce(callback) { useEffect(() => { return callback() }, []) }