Introducing Immer: Immutability the easy wayby@mweststrate
47,839 reads
47,839 reads

Introducing Immer: Immutability the easy way

by Michel Weststrate7mJanuary 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.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Introducing Immer: Immutability the easy way
Michel Weststrate HackerNoon profile picture
Michel Weststrate

Michel Weststrate

@mweststrate

Share Your Thoughts

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
L O A D I N G
. . . comments & more!