Answer the question
In order to leave comments, you need to log in
What is the correct way to update the component in this case?
Hello!
I implement logics with a ban on the re-rendering of the component if the button is clicked. Now the code is like this:
state = {
updatesLocked : false
};
shouldComponentUpdate(nextProps, nextState) {
return !nextState.updatesLocked
}
updatesButtonHandle = () => {
this.setState({
updatesLocked : !this.state.updatesLocked
});
}
render () {
const { updatesLocked } = this.state;
return (
<div className={styles.updatesButton} onClick={this.updatesButtonHandle} role="presentation">
{updatesLocked ? (
<div className={styles.lockIcon}>
<LockClosedIcon />
</div>
) : (
<div className={styles.lockIcon}>
<LockOpenIcon />
</div>
)}
</div>
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question