I’m going through a course and it talks about the constructor pattern. The instructor used a car object as an example but I thought it was similar to react and so that’s the naming convention I’m using
class Component {
constructor(props){
// this.name = props.name
for(const p in props){
this[p] = props[p]
}
}
}
According to my google research that’s where the constructor pattern ends (And I always thought so - though I’m a hobbyist beginner) but this instructor (Emmanuel Henri) says the constructor pattern is when we extend the class.
class App extends Component {
constructor(props){
super(props)
console.log(props)
}
}
const app = new App({name:"Bob", last: "Marley"})
Two questions.
- Is this a constructor pattern or just extending classes.
- Just for fun. in react the
App.render()
would that be a method within theComponent
class and called within the App?