I am looking at using the ES6 Map object to do my hashing for me, instead of creating a custom hashing function. However, it seems to me that it doesn't have much support for immutability, which is a key thing for React as well as Redux.
I am used to not using any libraries for immutability, but use just plain destructuring:
const newObj = { ...prevObj, newKey: "value" }
or map/filter with arrays.
However, ES6 Map has methods that directly update the object itself.
What I could think of was to do something like this:
var myMap = new Map()
Var myNewMap = { ...myMap.set() }
this.setState({ myMap:myNewMap })
But I am not sure if that would work.
If you just want a type-safe key-value store, you can use the following syntax:
entities: { [id: number]: MyEntity },
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With