I am working on a feature in a React application that allows users to click an image to set it as their dashboard background. The premise is pretty basic, when the user clicks the wallpaper setting in their menu settings, I perform an ajax request to a JSON file to grab the url of the images sitting on the server.
if(this.state.wallpaper === true) {
let x = 0;
var defaultWallpapers = this.state.content.map(image => {
x++;
// Need to set image as a background so we can overlay
// things on top of the image.
var backgroundStyle = {
backgroundImage: 'url(' + image.url + ')',
backgroundSize: 'cover'
}
return (
<div key={x} className="col-xs-4">
<div className="imageBox" style={backgroundStyle}></div>
</div>
);
})
}
else {
var defaultWallpapers = null;
}
Everything works great, except for one thing I would like to do. I want to set an overlay on whatever image the user selects. I got a version of that working, but like I assumed would happen, the overlay was applied to every image.
Does anyone have any pointers on how I would specifically target ONLY the image that is clicked by the user?