How react defines state

I happen to see that react has a very strange way of defining component state, which is like this

.
class Hello extends React.Component {
    // 
    constructor() {
        this.state = {
            name: "lan"
        }
    } 
    
    // 
    state = {
        name: "lan"
    }
}

is this the custom use of react (there is no such use of class for es6).

Jun.17,2021

this is the way ESNEXT is written.

escaped
https://babeljs.io/docs/en/ba.

supported by babel

proposal

https://github.com/tc39/propo.


Menu