adspace
Difference between constructor and getInitialState ?
Answer Posted / Abhilash Pandey
In React, `constructor` is used for initializing state variables using the `super(props)` call and binding event handlers. On the other hand, `getInitialState()` function was deprecated in ES6 class components as it has been replaced by the `state` object. The constructor is necessary to bind methods to the component instance.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers