dan’s alt Profile picture
secret alt of @dan_abramov2

Aug 18, 2020, 7 tweets

Tutorial: implementing undo/redo is so easy with immutability! You take the previous states and put them in an array and then you can

Reality: color picker putting every intermediate change into history as you drag the cursor is probably not quite what you intended

Tutorial: oh this is easy, you just snapshot only at important times, like when

Reality: good luck deciding when to snapshot your state, before the user has committed their action or after the action has already destroyed the previous state you were supposed to snapshot

This is not to throw shade at immutability. I know it's trying its best and I'm thankful for that

I'll still pick naïve undo/redo with flaws over "rearchitecture your whole app to make it work"

An unrelated action causing to snapshot in-progress state of another action that has not been fully confirmed by the user but has already been reflected to the screen -- OOPS.

I? Have to consciously design my data model to work with undo/redo in a way that makes sense to the user? Never! Paradigm, do the work for me

A more serious take

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling