I am trying to understand why this code would not work:
const [data, setData] = useState(() => {
var data = {
some_var: 0,
};
data["test"] = "test";
return data;
});
I get the following error:
Cannot assign "test" to data["test"] because property test is missing in object literal
but according to this post this is something I should be able to validly do in JS.