javascript - React - Change Color Of a specific div inside a map function - Stack Overflow

PHOTO EMBED

Sat Feb 11 2023 07:49:40 GMT+0000 (Coordinated Universal Time)

Saved by @winifredogbeiwi #react.js

const [state, setState] = useState(-1);
map((data, index) => (
  <Grid 
    onClick={() => setState(index)}
    style={{
      background: state === index ? 'lightblue' : 'white'
    }}
  >
))
content_copyCOPY

add to code

https://stackoverflow.com/questions/74179582/react-change-color-of-a-specific-div-inside-a-map-function