hello everyone.
I'm using the comlink-loader in ReactJS to load a class and call a function in off-thread.
it's a very basic function, only returns the given value (I'm gonna use it later to call API in off-thread), but I'm getting this error: Error: rawValue is undefined
here is my worker:
`//@todo: use writelog later to call API
// import { writeLog } from 'constants/Helpers/logHelpers';
I also should add when I use anormal function it works whti no problem
instead of using class i used below code.
export const offThreadLog = payload => { return payload; }
hello everyone. I'm using the comlink-loader in ReactJS to load a class and call a function in off-thread. it's a very basic function, only returns the given value (I'm gonna use it later to call API in off-thread), but I'm getting this error:
Error: rawValue is undefined
here is my worker:
`//@todo: use writelog later to call API // import { writeLog } from 'constants/Helpers/logHelpers';
export class LogWorker { // offThreadLog: payload => writeLog(payload), async offThreadLog(payload) { return payload; } }`
and this is how I loaded and called it
`//some imports import LogWorker from 'comlink-loader!constants/Workers/log.worker'; // some other imports
const Hoc = () => { useEffect(() => { const logWorker = new LogWorker(); window.addEventListener('click', async () => { const response = await logWorker.offThreadLog({ medium: 'HOC', detail: 'off thread log', action: 'click', }); console.log(response); }); }, []); }
export default Hoc;` I also tried the example in docs, but the same error happened. thanks.