reactjs - react-vr component stops showing in state change -
component stops showing in state change text component score, stops showing, score saved in state. not updating in view. text component show when initial state set. when button clicks state correctly updates , component stops showing. behavior changed before fontsize
, stops showing.
oninstrumentclicked(index) { console.log('oninstrumentclicked'); this.state.winsounds.foreach(function(e) { e.playerstate.pause(); }); this.state.winsounds[index].playerstate.play(); this.setstate( (prevstate, props) => { console.log('selected sound', index); console.log('correct sound', this.state.correct_sound); console.log('score', prevstate.score); console.log('props', props); return { score: index === this.state.correct_sound ? number(prevstate.score) + 1000 : number(prevstate.score) - 1000 }; }, () => { console.log(this.state.score); if (index === this.state.correct_sound) { if (this.state.cheertimeout) { clearinterval(this.state.cheertimeout); } this.state.cheertimeout = settimeout( playerstate => { playerstate.play(); }, 3000, this.state.cheerplayerstate ); } } ); } render() { return ( <text style={styles.score}> {this.state.score} {console.log(this.state.score)} </text> ); }
Comments
Post a Comment