I have:
const [list, setList] = useState([]);
Somewhere in the component, I want to do:
list[index][someKey] = some_updated_value;
setList(list);
Is this valid?
Or, is it better to do:
const newList = list;
newList[index][someKey] = some_updated_value;
setList(newList);
If this is better, Why?