dai-shi / react-hooks-worker

React custom hooks for web workers
MIT License
709 stars 17 forks source link

Dependency array #4

Closed rssfrncsrenishaw closed 5 years ago

rssfrncsrenishaw commented 5 years ago

Hi,

Just giving this library a try and wondering if there is a way to provide a dependency array like useEffect?

dai-shi commented 5 years ago

https://github.com/dai-shi/react-hooks-worker/blob/7efdf4f27a63dc9af64cdf3a23e85f3e33e6f6ae/src/index.js#L29

The second argument is passed into deps. So, you can control with it. This also means users have to useMemo to avoid unintentional invocations.

I'm interested in your use case.

rssfrncsrenishaw commented 5 years ago

Ah of course thanks.

My use case for web-workers in general? Or using this library?

I'm using workers to transform between data types with a really large dataset. I'm finding hooks are a really nice way to use them. I was using workerize beforehand (which is great, but this reduces the component code further).

dai-shi commented 5 years ago

Thanks. Have you tried comlink before?

Also, I updated this library since then. If you have a chance, please give it a try.

Closing this issue. You can continue posting feedback after that, or create a new issue.