DEV Community

Discussion on: React Hook to Allow Undo/Redo

Collapse
 
zyabxwcd profile image
Akash • Edited

cool. at the beginning it seemed like a very complicated feature to implement. will this implementation work efficiently for more complicated tasks where the state is not just a simple text? have you tried something more complex with this implementation? and are you aware of any alternative implementations?

Collapse
 
jeremyling profile image
Jeremy

Yes I use this in production for a drag and drop form builder to store the historical state of the form for undo/redo purposes. The form in this case is typically a deeply nested object storing serializable and non-serializable (Dates, functions, blobs, files, HTML elements) types.

I'm sure there are many implementations for undo/redo functionality. As the saying goes, there's a hook for everything. If there are further requirements you need (maybe diffing), you can extend this or search for other solutions.