We are Coltor Apps ― a software development agency behind this OSS. Need a reliable tech partner?

Let’s talk

React API Reference

useInterpreterStore

This React hook creates an interpreter store.

Reference

useInterpreterStore(builder, schema, options?)

Use the useInterpreterStore function to create an interpreter store.

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

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

const formSchema = {
  entities: {
    "51324b32-adc3-4d17-a90e-66b5453935bd": {
      type: "textField",
      attributes: {
        label: "First name",
      },
    },
  },
  root: ["51324b32-adc3-4d17-a90e-66b5453935bd"],
};

export function App() {
  const interpreterStore = useInterpreterStore(formBuilder, formSchema);
}

In the example above, we've hardcoded the schema, but typically, you would fetch it from some data source, for instance.

Parameters

useInterpreterStore accepts three parameters:

ParameterTypeDescription
builderobjectThe builder definition.
schemaobjectThe schema that was built using the provided builder definition.
optionsobject optionalAn optional partial object with initialization options.

You should know!

Ensure that the provided builder and schema parameters remain stable or are memoized. The interpreter store will be recreated if these references change, leading to data loss.

Options

The options parameter properties:

PropertyTypeDescription
initialDataobject optionalThe optional partial initial data of the interpreter store.
initialEntitiesValuesWithDefaultsboolean optionalA flag to enable or disable the automatic setting of default values. Defaults to true.

Returns

The useInterpreterStore function essentially creates and returns an interpreter store.

Previous
<BuilderEntity />

Canary Branch