Skip Navigation

Should I use arrow functions or class function style

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() {}

11

You're viewing a single thread.

11 comments
  • No diff with typescript, tho declared is more flexible because you can overload it. Declared (classic) functions are hoisted and can be used prior to their declaration. Not sure on perf differences

    • 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.

11 comments