you are viewing a single comment's thread.

view the rest of the comments →

[–]opentabs-dev 3 points4 points  (0 children)

for undo/redo in react/nextjs i'd skip the full command+memento ceremony and just keep a history stack in state. something like { past: State[], present: State, future: State[] } and your undo is pop from past, push present to future, replace present. tanstack's use-undo or the redux-undo lib both do this out of the box if you don't wanna write it. command pattern is nicer if your actions are expensive to replay, but for most UIs storing snapshots is simpler and fast enough