I am trying to put style on the selected div onClick
let woods = pageURL.map( (wood, key)=> {
if(wood.internal_doors_style[0] === this.state.slug_style) {
if(this.state.selected) {
sel = 'red'
}
return (
<div style={{background: sel}} key={wood.id} className="menu-item wood-item filter-wood" id={wood.id} onClick={()=> this.setW(wood.internal_doors_wood[0])}>
<img src={wood.acf.wood_image.url} alt="" width="40"/>
<span className="span">{wood.acf.woods_title}</span>
</div>
)
}
})
the problem I am having that the style is applying on all the element not the selected one only.
this.setState({
slug_wood: w,
selected: !this.state.selected
})
return single_data = <SingleInternal wood={this.state.slug_wood} style={ this.state.slug_style}/>
}
is there a way maybe to target the id of each element where I set the id of each element to be unique id={wood.id}