iamshaunjp / iamshaunjp/react-context-hooks

state in constructor or not

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
400
Forks
346
PR merge metrics
No merged PRs in 30d

Description

Hi, Ninja,

I have watched the 2 series of your React toturials, and I have noticed that you like to use `state` directly in the class, instead of to put it in the `constructor` like the React documentation does.

```javascript
class Foo extends Component{
state: {
name: "Shaun"
}
}

class Bar extends Component {
constructor(props){
super(props);
this.state= {
name: "Shaun"
}
}

}
```

So, would you please explain it a little bit about why you prefer to use `state` like the above class Foo ? Thanks.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.