Skip to content

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

@Snaylaker

Description

@Snaylaker

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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions