简体   繁体   English

使用 class 语法的粗箭头语法反应 WebWorker

[英]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.我是 React 新手,一直在使用胖箭头语法和功能组件开发个人项目。 From what I've read, that is the new and best way to currently develop in React.根据我的阅读,这是目前在 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.但是,我一直无法在 react 中找到使用箭头语法的 webworkers 示例,所有示例都使用function() ,这是我试图避免的。 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 PS:我使用的是 JavaScript 版本的反应,而不是 TypeScript

You can create a functional component like this and also can create a arrow function too.您可以像这样创建一个功能组件,也可以创建一个箭头 function。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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