DEV Community

Discussion on: React - ES6 tricks in Classes

Collapse
 
puritanic profile image
Darkø Tasevski

Using constructor is not the old way, it's still a viable way to construct a state, and in the end this:

state = {
    value: ""
  }

is transpiled to this:

 constructor(props) {
    super(props);
    this.state = {
     value: ""
    };
  }

So. it's not the old way, it's just syntatic sugar.

Using arrow functions to bind methods to the class is really useful tho.

Collapse
 
kozakrisz profile image
Krisztian Kecskes • Edited

True story! :-) That is right!
I meant "old way" and "new way" like... we "used that way" and we "should use this way". :-)