SU
За неимением опыта я хз как правильно сделать, чтобы все было четко :D
Size: a a a
SU
NR
V
CM
K
K
ДФ
V
V
V
В
В
const [elemList, setElemList] = useState(getElemList);
const getElemList = blockList.map((elem, index) => {
// handleClick(elem, index)
const handleClick = () => {
const newElem = {...elem, name: new Date().toString()}
const newList = elemList.slice();
newList[index] = newElem;
setElemList(newList);
}
console.log(elemList)
return (
<div className="block-elem" key={index} onClick={handleClick}>
{ elem.name }
</div>
)
})
CM
В
В
V
const [elemList, setElemList] = useState(blockList);
const getArrList = elemList.map((elem, index) => {
const handleClick = () => {
const newElem = {...elem, name: Math.random(10)}
const newList = elemList.slice();
newList[index] = newElem;
setElemList(newList);
}
return (
<div className="block-elem" key={index} onClick={handleClick}>
{elem.name}
</div>
)
})
V
W
M