ReactJS Functional Component Syntax in 1 minute

Makzan
·
·
IPFS
·
Learn how to use const, object extraction, and single-line function to write a basic functional component in ReactJS. Part of the 1-minute Web Technologies video series.

Hey there, this is Thomas from Macao.

In this video, I’m going to explore the functional components of ReactJS.

Traditionally, we define a function like this. We have literally the function word, the name, the parameters, curly brackets, and then the lines of code inside the brackets scope.

We can reduce the code by minimizing the syntax usage. We can turn the function definition into const, function name, an object of attributes we need in properties as the parameters. The fat arrow syntax. Then if this is a simple component with one line of code, we don’t even need the curly brackets and the return wording.

But for better readability, I will wrap the code with a pair of parentheses.

That’s it for a basic functional component syntax.


CC BY-NC-ND 2.0 授权

喜欢我的作品吗?别忘了给予支持与赞赏,让我知道在创作的路上有你陪伴,一起延续这份热忱!

logbook icon
Makzan我管理世界職業技能競賽之網站技術項目、舉辦本地設計與開發賽事、開課分享技術心得。一個用網頁來表達自己的作家。
  • 来自作者
  • 相关推荐

期望與放下

甚麼是世界職業技能競賽

【最後兩天】買《所謂「我不投資」,就是 all in 在法定貨幣》親身體驗擁有 NFT