Skip to content

Mutating State App Component #1

@jlag34

Description

@jlag34

In App in removeTrack you have:

let newTracksState = this.state.playlistTracks;

Anything you do to newTrackState will mutate the component’s state and is very bad in React. Try something like this:

let newTracksState = this.state.playlistTracks.slice();

Using slice without any arguments will return a new copy of the entire array. This will let you use the variable safely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions