9
4 Comments

How to Implement Undo in a React + Redux Application

  1. 1

    "Collaboration," or multiple users performing autosaved work at the same time, is an additional consideration for implementing undo/redo stacks. A page that has heavy collaboration will need more care. If the app will mostly have one user and sometimes two, you probably don't need to think too hard about this.

    Two users might issue saves / undos at the same time. This can have two problems: first, the behavior of one user can unexpectedly overwrite what another user is doing (in a last-write wins setup). It turns out that users get upset when their changes get stomped by someone else. Or if their actions are partial updates that get merged together, you need to be careful that the synthesized result doesn't result in an illegal state, both for the undo and the redo.

    There are other hidden gotchas that can come up occasionally: making sure that users always have permissions to execute all of the "undo" and "redo" actions, making sure that deletions from one user doesn't wipe out a ton of work from the other user, etc. But it's worth suffering through all of this for the user experience!

  2. 1

    Thanks for sharing! Very helpful.

  3. 1

    Why still using Redux? Was it just too hard to get off of? Uclusion has a blog about getting off the React + Redux combination.

    1. 1

      I think there's pros and cons for all the different forms of state management and there's no true silver bullet. I've used redux by itself, redux + context, context by itself, etc. They all have their specific use cases in my opinion.

Trending on Indie Hackers
After 10M+ Views, 13k+ Upvotes: The Reddit Strategy That Worked for Me! 42 comments Getting first 908 Paid Signups by Spending $353 ONLY. 24 comments 🔥Roast my one-man design agency website 21 comments I talked to 8 SaaS founders, these are the most common SaaS tools they use 19 comments What are your cold outreach conversion rates? Top 3 Metrics And Benchmarks To Track 19 comments Hero Section Copywriting Framework that Converts 3x 12 comments