Is initializing component's instance variable in getInitialState relevant?
For example:
var Chat = React.createClass({
getInitialState: function() {
this.messages = []; // Instance variable initialization - EDIT: better as state variable?
this.scrollToBottom = false; // EDIT - Instance variable which is not a state
return {
messages: [],
};
},
componentDidUpdate: function() {
if(this.scrollToBottom){
// Animate DOM
this.scrollToBottom = false;
}
},
// ...
});
I would like to do that to make react component's code cleaner.
Thank you for helping