TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

When to Use Arrow Functions with React

3 pointsby jamesknelsonalmost 8 years ago

1 comment

uwualmost 8 years ago
&gt; However, if you’re using Babel (or create-react-app) to build your source, you have another option: setting arrow functions as class fields (or arrow function methods).<p>&gt; This gives you the best of both worlds. You get the improved performance from only defining functions once, but you still get the simple method-like syntax.<p>i think this is wrong because class fields are evaluated in the constructor<p>i dislike the class fields proposal because it&#x27;s confusing (as shown by the article) and adds little value (can already use a constructor) and lets you sprinkle the fields all over the class definition instead of having them in one place (the constructor)<p>also, how it makes own properties instead of prototype properties which would be consistent with how methods are already defined in the class body<p>only the static fields part of the proposal is good because it&#x27;s useful (there&#x27;s no constructor for static fields) and behaves as expected (no &quot;own property vs prototype property&quot; question to get wrong)