Nick
0
Q:

pass variable to setstate callback

selectHandler(event){
    const { target } = event;

    this.setState({
        selectedImage: target
    }, () => {
        this.markSelectedHandler(target)
    })
}

markSelectedHandler(target){
    target.classList.add('active')
    if(target!== this.state.selectedImage && this.state.selectedImage){
        this.state.selectedImage.classList.remove('active')
        target.classList.add('active')
    }
}
2

New to Communities?

Join the community