DEV Community

Discussion on: Learn Public Class Field Syntax by Refactoring a React Component

Collapse
 
darrenvong profile image
Darren Vong • Edited

When we use class fields to add methods [...], the class fields are added to the instance itself instead of the prototype.

Interesting, I did not know this before reading your post! For maintainability, I tend to prefer clean code over worrying about micro optimisation details, but I can definitely see this adding performance overhead if lots of these components are needed for an app. I'll certainly bear this in mind when writing future React components!

Collapse
 
jung2x profile image
Jung2x

Agree, quick write & clean code first, optimisation later

Collapse
 
kakakcii profile image
kakakcii

I'd verify that bit of information before "bearing that in mind"