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

Introducing Immer: Immutability the easy way

January 1st 2018
8 min
by @mweststrate 47,451 reads
tldt arrow
Read on Terminal Reader🖨️

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

@mweststrate

Michel Weststrate
react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa