InterviewSolution
| 1. |
What Is The Difference Between Using Constructor Vs Getinitialstate In React / React Native? |
|
Answer» The two approaches are not interchangeable. You should initialize STATE in the constructor when using ES6 classes, and define the getInitialState METHOD when using React.createClass. class MyComponent EXTENDS React.Component { is equivalent to var MyComponent = React.createClass({ The two approaches are not interchangeable. You should initialize state in the constructor when using ES6 classes, and define the getInitialState method when using React.createClass. class MyComponent extends React.Component { is equivalent to var MyComponent = React.createClass({ |
|