You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did not realize that every time I was creating a new list with List(), I was getting the same instance of List. This seems counterintuitive in a library based on the idea of immutability.
Some code in the project was mutating an instance of an empty list which caused all subsequent newly minted lists to be non-empty. Obviously the code in my project was incorrect, but I came here to suggest not using a singleton pattern here regardless.
The text was updated successfully, but these errors were encountered:
Nice catch. A possible fix would be either to make the new list not mutable, or create a new list every time, or reset EMPTY_LIST if it has been mutated.
That's funny...In our project we made our own EMPTY_LIST to allow skipping React's "did something change" checks when consecutive calls returned nothing.
I am a bit suprised that we seem to just have done that as a reaction to reading the code, because a test would obviously have caught that
I just ran down a nasty bug related to this code below:
immutable-js/src/List.js
Line 413 in 493afba
I did not realize that every time I was creating a new list with
List()
, I was getting the same instance ofList
. This seems counterintuitive in a library based on the idea of immutability.Some code in the project was mutating an instance of an empty list which caused all subsequent newly minted lists to be non-empty. Obviously the code in my project was incorrect, but I came here to suggest not using a singleton pattern here regardless.
The text was updated successfully, but these errors were encountered: