Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: rawValue is undefined in comlink-loader #23

Open
rezaerami opened this issue Apr 14, 2020 · 1 comment
Open

Error: rawValue is undefined in comlink-loader #23

rezaerami opened this issue Apr 14, 2020 · 1 comment

Comments

@rezaerami
Copy link

rezaerami commented Apr 14, 2020

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.

@rezaerami
Copy link
Author

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; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant