this post was submitted on 18 Jun 2023
12 points (100.0% liked)

React

890 readers
1 users here now

A community for discussing anything related to the React UI framework and it's ecosystem.

https://react.dev/

Wormhole

[email protected]

Icon base by Skoll under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

This may be a very stupid question. But I was wondering if I should be using arrow function syntax or the classic function syntax for react components now or is this purely a style choice. I ask this purely as someone trying to work towards industry standards but have found a tremendous amount of mixed comments on it. Also is there any difference using typescript?

Example: const foo = () => {}

Or

function foo() {}

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 7 points 1 year ago (1 children)

I was doing some research and it seems like arrow function preserves 'this' context. Might be a reason to either classic or arrow. The overloading seems like a valuable option too.

[โ€“] [email protected] 1 points 1 year ago

Good call. Yah overloading is the way to go for complex function signatures in typescript