Immutability in React and Redux: The Complete Guide
CRANK

Immutability can be a confusing topic, and it pops up all over the place in React, Redux, and JavaScript in general.You might’ve run into bugs where your React components don’t re-render, even though you know you’ve changed the props, and someone said, “You should be doing immutable state updates.” Maybe you or one of your teammates regularly writes Redux reducers that mutate state, and you have to constantly correct them (the reducers, or your teammates 😄)It’s tricky. It can be really subtle, especially if you’re not sure what to look for. And honestly, if you’re not sure why it matters, it’s hard to care.This guide will explain what immutability is and how to write immutable code in your own apps. Here’s what we’ll cover:What Is Immutability?First off, immutable is the opposite of mutable – and mutable means changeable, modifiable… able to be messed with.So something that is immutable, then, is something that cannot be changed.Taken to an extreme, this means that ins…

codeproject.com
Related Topics: React JavaScript GitHub