I've seen both used interchangeably.
What are the main use cases for both? Are there advantages / disadvantages? Is one a better practice?
constructorreact-nativereactjs
I've seen both used interchangeably.
What are the main use cases for both? Are there advantages / disadvantages? Is one a better practice?
Best Solution
The two approaches are not interchangeable. You should initialize state in the constructor when using ES6 classes, and define the
getInitialStatemethod when usingReact.createClass.See the official React doc on the subject of ES6 classes.
is equivalent to