Skip to content

Tag: immutability

React setState does not update a state array value

I am trying to change the state in a class component by using setState. More specific I have a table, and I want to edit/update one of its elements. For this case, I am passing the indeces to the handleTableFieldOnChange function for the position of the value in the array. Since I know that I should not mutat…

Enums in Javascript with ES6

I’m rebuilding an old Java project in Javascript, and realized that there’s no good way to do enums in JS. The best I can come up with is: The const keeps Colors from being reassigned, and freezing it prevents mutating the keys and values. I’m using Symbols so that Colors.RED is not equal to…