dispix / react-pirate

MIT License
52 stars 6 forks source link

fix(useUnmount): use a memoized function #4

Open ckknight opened 6 years ago

ckknight commented 6 years ago

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.

dispix commented 6 years ago

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 ?