React API Reference

useBuilderStore

This React hook creates a builder store.

Reference

useBuilderStore(builder, options?)

Use the useBuilderStore function to create a builder store.

import { useBuilderStore } from "@coltorapps/builder-react";

import { formBuilder } from "./form-builder";

export function App() {
  const builderStore = useBuilderStore(formBuilder);
}

Parameters

useBuilderStore accepts two parameters:

ParameterTypeDescription
builderobjectThe builder definition.
optionsobject optionalAn optional partial object with initialization options.

The options parameter properties:

PropertyTypeDescription
initialDataobject optionalThe optional partial initial data of the builder store.
eventsobject optionalAn optional partial object with events callbacks.

Returns

The useBuilderStore function essentially creates and returns a builder store.

Events Callbacks

Each event emitted by the builder store is available as a callback within the events key of the options parameter. Every callback receives a specific payload based on the event.

CallbackDescription
onEntityAddedAn entity was added.
onEntityUpdatedAn entity was updated.
onEntityAttributeUpdatedAn entity's attribute was updated.
onEntityDeletedAn entity was deleted.
onEntityClonedAn entity was cloned.
onRootUpdatedThe root was updated.
onEntityAttributeErrorUpdatedAn entity's attribute error was updated.
onSchemaErrorUpdatedThe schema's error was updated.
onSchemaUpdatedThe schema was updated.
onDataSetThe data was manually set.
Previous
validateEntitiesValues