I want to create an Immutable Set of paths. A path, in my case, is just an array of strings. So let's say we have the following paths.
var paths = [["a"], ["a", "b", "c"]];
I then create the Immutable Set like this
var selectedPaths = Immutable.Set(paths);
Although selectedPaths.first()
returns ["a"]
, I cannot understand why selectedPaths.contains(["a"])
returns false
.
EDIT: Well, I got an answer as to why this is happening, but I still cannot get it to work as I need it to.
SOLUTION: As @Alnitak has stated, I solved this by comparing a path to Immutable.List(["a"])
instead of a simple array
According to the docs, Immutable uses the Immutable.is()
function to perform equality checks, but that .is()
check only performs "value comparison" checks when given other Immutable.*
objects, and not native JS arrays, for which it performs a "reference comparison" check.
Therefore, try storing your inner values as an Immutable.List
instead of as a plain JS array.
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