简体   繁体   中英

React WebWorker using fat arrow syntax insted of class syntax

I'm new to React and have been developing a personal proyect using the fat arrow syntax and functional components. From what I've read, that is the new and best way to currently develop in React.

I've currently find myself in need of doing some threading, and research has pointed me in the direction of web-workers. However, I've been unable to find an example for webworkers in react that uses the arrow syntax, all examples use a function() which is what I'm trying to avoid. Could anyone give an example on how I could do this? I really don't know how to do any of this, the creation of the worker, the posting and recieveng of messages and the termination.

PS: I'm using JavaScript version of react, not TypeScript

You can create a functional component like this and also can create a arrow function too.

const YourFunction = (props)=>{
       return ()
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM