Closed adrianhelvik closed 4 years ago
Thank you! I love it! Sorry if it not going to merge it straight away but I need to think a little about how well it works in the wild (by looking at actual hooks that accept a dependencies array).
That's perfectly okay. It's a good idea to not rush API additions.
useAsyncEffect would be a great candidate for using auto()
:
https://www.npmjs.com/package/use-async-effect
auto()
as I implemented it would work well with this as dependencies are retrieved from all function expressions in the hook call. I will publish the updated package at @adrianhelvik/hooks.macro
and test things out!
Edit: It's now available at @adrianhelvik/hooks.macro if you want to test it out.
Hooks usage in the wild seems to be all over the place, and equal function references seems to be the bast pattern imo.
(though auto() is fantastic)
I wrote a basic version of
auto()
. It can be used like this:turns into
I used inline snapshot output to avoid wrestling with Jest. Will update that later.
What do you think?