Skip to content

Commit 8e15362

Browse files
committed
forms: Add a useHistoryTracker hook for forms that track changes in objects
This is a React hook version of the current ChangeEventsForm. It tracks the valid and invalid changes to an object with numeric ID, storing the invalid fields without updating the object and updating the object when valid values are set. The hook needs to be passed the object to track changes on. It will return the following functions to the consumer: * onValueChange: callback to call when the value of an object's attribute is changed. It will handle the change and udpate the object. It will not track it, to allow side-effect of the change done by the form calling it. * canUndo: returns whether there are changes that can be undone * canRedo: returns whether there are changes that can be redone * undo: undo the last change, it will update the object * redo: redo the last change, it will update the object * hasInvalidFields: return whether there are invalid fields in the form * updateHistory: Track the current object state
1 parent 3b7e7ad commit 8e15362

File tree

2 files changed

+738
-0
lines changed

2 files changed

+738
-0
lines changed

0 commit comments

Comments
 (0)