PDA

View Full Version : State the difference between getIntialState() and constructor()?



adulistravel
04-30-2020, 07:43 PM
State the difference between getIntialState() and constructor()?

dennis123
05-08-2020, 02:25 AM
Hi Friend,
OK, the big difference is start from where they are coming from, so constructor is the constructor of your class in JavaScript, on the other side, getInitialState is part of the lifecycle of React . The constructor method is a special method for creating and initializing an object created with a class.