useBuilder
useBuilder()
#
#
Use ๐งA React hook that provides a set of utilities to retrieve the current builder state and builder history.
#
Signature ๐๏ธ#
Example Usage ๐#
Parameters ๐ฅThis hooks receives no parameters
#
Return Value ๐คjson: () => tree: Object
Return an object representation of the current builder state.
note
The returned tree object might or might not be serializable. It will not be serializable if you lifted data, such as a node props, with non-serializable values like functions.
loadTree: (tree: Tree | Object) => void
Loads builder state, must likely previously returned from the json() function. It should be a valid object representation of a builder state. Providing a non-valid builder representation will have unexpected behavior.
note
The tree object to load can, in theory, be non-serializable. Build UI uses Redux internally, so make sure you understand the drawbacks before loading non-serializable values.
canUndo: Boolean
Flag that indicates whether there are any actions to undo.
canRedo: Boolean
Flag that indicates whether there are any actions to redo.
handleUndo: () => void
Function to handle a history undo.
note
If handleUndo is called when there are no actions to undo, it will not do anything
handleRedo: () => void
Function to handle a history redo.
note
If handleRedo is called when there are no actions to redo, it will not do anything
history: Object
An object representation of the current builder history. You should treat is as a read-only property, so modifying this object will not modify the actual builder history.