reactbook
reactbook copied to clipboard
Story log in Excel does not record the first change
Since a strange ternary expression does not save the first "newState" value, the first is not saved to __log variable.
The fix may be as follows:
, _logSetState: function(newState) {
if ( this._log.length === 0 ) { // log first state
let firstStateClone = this.state;
this._log.push(firstStateClone);
}
// always log newState
let stateClone = JSON.parse( JSON.stringify(newState) );
this._log.push(stateClone);
this.setState(newState);
}