Closed ThinkSalat closed 5 years ago
Hi,
./slow_fib.js
should be accessible from the browser. So, you need to put the file in something like public
, not src
which is to be bundled by webpack or alike.
I know it's not very handy. I'm looking for better API.
Interesting.
I was looking at these:
The problem for me is that I don't want to limit the API to only RPC style.
The use case I'm going for is to render a react chart in a webworker and send back the html string in a message using renderToString. Does this seem doable?
Although I never tried, I think it's technically doable if it's "String". (but then how would you apply it to DOM?)
In general, rendering react components in worker is not straightforward, and I know only react-native-dom successfully did that.
https://www.npmjs.com/package/react-hooks-worker/v/0.4.0
You no longer need to have a separate file. Just put a function inline. Please check out README and example/04.
Closing this issue. Feel free to open a new issue or continue discussion in this issue if it's relevant.
I'm not sure what's going wrong. I coped the slow_fib.js from the examples. and am linking to it like this:
let { result, error } = useWorker('./slow_fib.js', 29);
All I am getting is null for result and 'error' for error. I commented out the whole file, and got the same thing...