-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Breaking change between 3.x and 4.x #1504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is anyone else concerned about .toArray() working differently in the new version? I would need to change 100s of places to call .toList().toArray() instead of just .toArray() like in 3.x. |
#1340 indicates that this is likely to be a change that sticks. The justification is to more generally make the behavior of const nativeMap = new Map([['key', 'val']]);
// Map(1) {"key" => "val"}
Array.from(nativeMap);
// [["key", "val"]] From that PR, the recommended code transform is This is definitely a big breaking change and should be loudly called out in the final release notes for 4 stable. |
Ok :-( I suppose if React accepted the results of a call like <div>
{Map({
name: 'Andy'
}).map((item, key) => <div key={key}>Something</div>)}
</div> Then it would be no problem. We could just remove the code :) |
About the
The question is that shall we fix that part of code? Personally I think the immutable v-4's result seems more sensible. @acusti |
The change from Map.toArray => [...values] to [...[key, value]] is more familiar to how ES6 Map works and I think it's change that should stay. The case of changing toArray() to toList().toArray(), could be fixed via some sort of codemod? |
Sounds good. Should I close this? |
@richtera yes, please close this |
What happened
map.toArray() changed to return elements using [key, value] instead of just returning value.
This causes fatal breaks in most of my react code. I think toArray should stay and maybe add a toArrayElements() or something.
How to reproduce
The text was updated successfully, but these errors were encountered: