react-pirate icon indicating copy to clipboard operation
react-pirate copied to clipboard

fix(useUnmount): use a memoized function

Open ckknight opened this issue 7 years ago • 1 comments

Because of the use of the [] cache, only the first function that was passed in would have been used during the unmount process. This ensures that the most recent render's fn will be used on the final unmount.

The same consideration does not need to be taken for useMount.

ckknight avatar Nov 02 '18 23:11 ckknight

Ok so I get the problem and was able to reproduce it although your solution doesn't seem to work either ? Here's a small sandbox with the test : https://codesandbox.io/s/71pxo9nkzx

Am I missing something ?

dispix avatar Nov 03 '18 09:11 dispix