componentDidUpdate: function(prevProps) { if (prevProps != this.props) { this.setState(update(this.state, { values: {$set: []} })); } },
componentDidUpdate: function(prevProps) { if (prevProps != this.props) { this.setState(update(this.state, { text: {$set: ""} })); } },
nextQuestion: function(answer) { let question = this.props.questions[this.state.questionIndex] let answers = fromJS(this.state.answers) .set(question.name, answer.value) .toJS(); let finished; let index; if (this.props.questions.length - this.state.questionIndex == 1) finished = true; else { let relativeIndex = this.props.questions.slice(this.state.questionIndex + 1).findIndex(q => this.questionMustBeAsked(q)); finished = (relativeIndex == -1); index = relativeIndex + this.state.questionIndex + 1; } this.setState(update(this.state, { questionIndex: {$set: finished ? 0 : index}, answers: {$set: finished ? {} : answers} }), () => { if (finished) { this.onAnswered(answers); } }); },
onChange: function(value) { let index = this.state.values.findIndex(v => v == value); this.setState(update(this.state, { values: {$set: index == -1 ? fromJS(this.state.values).push(value).toJS() : fromJS(this.state.values).remove(index).toJS()} })); },
updateTasks: function() { this.setState(update(this.state, { tasks: {$set: store.getState().tasks} })); },
handleStateChange: function() { this.setState(update(this.state, { filePath: {$set: store.getState().package.filePath}, config: {$set: store.getState().package.config} })) },