Skip to content
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

[Suggestion]: use toSorted and toReversed for the examples in Updating Array in State Page #7134

Open
Snaylaker opened this issue Aug 29, 2024 · 2 comments

Comments

@Snaylaker
Copy link

Summary

Update this section Updating arrays without mutation by adding toReversed() and toSorted() instead of suggestion cloning the array and mutating it.

Page

https://react.dev/learn/updating-arrays-in-state

Details

Since toReversed() and toSorted() have been added to Javascript, should the docs reflect the changes and remove the section about mutating the array before sorting and reversing?

Or does it stay just to give an example of cloning before mutating an array ?

@BrianWoolfolk
Copy link

I would like to work on this issue

@BrianWoolfolk
Copy link

You can see my PR #7174 for this issue.

I considered appropriate to also add a Note block regarding the similarities between the new methods and the spread syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants