react-use-comlink
react-use-comlink copied to clipboard
Unexpected token '<'
trafficstars
I created a simple object similar to the example:
import { expose } from 'comlink'
export const SortWorker = {
hello: 'world',
sort() {
return 'sort worker ran!'
},
}
expose(SortWorker)
But I see this in the console: Uncaught SyntaxError: Unexpected token '<'
I am using create-react-app with hooks.
your route seems to be returning HTML instead of JS, check the body of the request
CRA uses Webpack 4 which does not natively support importing Workers. You need to add the worker-loader. Once CRA updates to use Webpack 5, you may be able to remove this loader.