コード例 #1
0
 componentDidUpdate: function(prevProps) {
   if (prevProps != this.props) {
     this.setState(update(this.state, {
       values: {$set: []}
     }));
   }
 },
コード例 #2
0
 componentDidUpdate: function(prevProps) {
   if (prevProps != this.props) {
     this.setState(update(this.state, {
       text: {$set: ""}
     }));
   }
 },
コード例 #3
0
 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);
     }
   });
 },
コード例 #4
0
 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()}
   }));
 },
コード例 #5
0
 updateTasks: function() {
   this.setState(update(this.state, {
     tasks: {$set: store.getState().tasks}
   }));
 },
コード例 #6
0
 handleStateChange: function() {
   this.setState(update(this.state, {
     filePath: {$set: store.getState().package.filePath},
     config: {$set: store.getState().package.config}
   }))
 },