How to change state in Redux

Example

# storeperson = {
name: 'John Doe',
age: 26,
booksIHave: ['A', 'B', 'C']
}
# containerexport default connect(
state => ({
person = state.person
}),
dispatch => bindActinonCreators({ updatePerson }, dispatch)
)

Don’t do like this

updatePerson({...person, booksIHave[0] = 'D'})

Best Practice

newBooksIHave = ['D', 'B', 'C']
updatePerson({...person, booksIHave: newBooksIHave})

Reason

Started LinkedIn as well!

https://www.linkedin.com/in/tomoharu-tsutsumi-56051a126/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store