Skip to content

Commit 4357aeb

Browse files
committed
refactored note scu
1 parent 7bcbdcb commit 4357aeb

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

native/src/components/Note.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ class Note extends React.PureComponent {
3939
await this.stopPlayingNote();
4040
}
4141
}
42-
// shouldComponentUpdate(nextProps, nextState) {
43-
// // TODO: split into consts
44-
// // return true;
45-
// const shouldUpdate = this.state.isLoading || (nextProps.name !== this.props.name) || (nextProps.instrumentName !== this.props.instrumentName) || (nextState.isPlaying !== this.state.isPlaying) || (nextProps.play !== this.props.play) || this.state.isPlaying || this.state.isPlaying !== nextState.isPlaying;
46-
// return shouldUpdate;
47-
// }
42+
shouldComponentUpdate(nextProps, nextState) {
43+
// TODO: split into consts
44+
// return true;
45+
const isLoading = this.state.isLoading || nextState.isLoading;
46+
const isPlaying = this.state.isPlaying !== nextState.isPlaying;
47+
const isPlayingControlled = this.props.play !== nextProps.play;
48+
const shouldUpdate = isLoading || isPlaying || isPlayingControlled; // this.state.isLoading || (nextProps.name !== this.props.name) || (nextProps.instrumentName !== this.props.instrumentName) || (nextState.isPlaying !== this.state.isPlaying) || (nextProps.play !== this.props.play) || this.state.isPlaying || this.state.isPlaying !== nextState.isPlaying;
49+
return shouldUpdate;
50+
}
4851
componentWillUnmount() {
4952
this.sound.release();
5053
}

0 commit comments

Comments
 (0)