Skip to content

Mutating state #32

@pobch

Description

@pobch

I think you are mutating the state at the following lines:

const notes = [...state.notes]
notes[index].completed = !note.completed

Since each note is an object, setting notes[index].completed property is mutating the note object. Instead, we should create a new note object like this:

const notes = [...state.notes]
notes[index] = { ...state.notes[index], completed: !note.completed }

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