GoogleChromeLabs / GoogleChromeLabs/comlink

not working in react

Open
#437 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.8k
Forks
435
PR merge metrics
No merged PRs in 30d

Description

I tested all examples in a react application but it don't works
how can I use it in react?

worker.js
```javascript
import * as Comlink from 'comlink';

async function callbackFunction(cb) {
await cb("A string from a worker");
}

Comlink.expose(callbackFunction);
```

index.ts
```javascript
import * as Comlink from 'comlink';

function callback(value) {
alert(`Result: ${value}`);
}
async function init() {
const remoteFunction = Comlink.wrap(new Worker("worker.js"));
await remoteFunction(Comlink.proxy(callback));
}
init();
```
for example I call this but it does not execute

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.