Kayut
Posted on January 18, 2019
Does a Class component in React need to have a constructor like the following example:
class App extends React.Component {
constructor() {
super()
this.state = {
count: 0
}
}
render() {
...
}
}
Or now we can define a Class component without using a constructor, like the following example?:
class App extends React.Component {
this.state = {
count: 0
}
render() {
...
}
}
Which one is correct?
Do we still need to write the constructor for a Class component?
đź’– đź’Ş đź™… đźš©
Kayut
Posted on January 18, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
undefined JavaScript and SaaS: The Dynamic Duo Behind Scalable and Interactive Applications
November 17, 2024