paint-brush
Introducing Immer: Immutability the easy wayby@mweststrate
47,887 reads
47,887 reads

Introducing Immer: Immutability the easy way

by Michel WeststrateJanuary 1st, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Immutable data structures are a great paradigm for storing state. But in a language like JavaScript, producing a new state from the previous one is a boring, boiler-platy task. Introducing Immer: Immutability the easy way to use persistent data structures in ReactJS. Immer works by writing producers, and the simplest producer possible looks like this: const nextState = produce(currentState, draft) The next state is simply the state we started with. All changes to draft are reflected in the next state, which structurally shares untouched items.
featured image - Introducing Immer: Immutability the easy way
Michel Weststrate HackerNoon profile picture
Michel Weststrate

Michel Weststrate

@mweststrate

L O A D I N G
. . . comments & more!

About Author

Michel Weststrate HackerNoon profile picture
Michel Weststrate@mweststrate

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite