For this piece of code, !this.state.dark
I am getting an ESlint (airbnb config) error:
Use callback in setState when referencing the previous state.
I tried refactoring the code using following the ESlint documentation. But I'm having a hard time figuring it out. Any suggestions on how I can solve this problem?
toggleDark = () => {
const dark = !this.state.dark
localStorage.setItem('dark', JSON.stringify(dark))
this.setState({ dark })
}