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

Let’s talk

React API Reference

useBuilderStoreData

This React hook accepts a builder store, listens for data updates, and returns the latest data. Each data update triggers a re-render. You can optionally provide a custom selector as the second argument to gain fine-grained control over re-renders and data selection.

Reference

useBuilderStoreData(builderStore, selector?, comparator?)

Use the useBuilderStoreData function to subscribe to the builder store's data updates and retrieve the data.

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

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

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

  const data = useBuilderStoreData(builderStore);
}

Parameters

useBuilderStoreData accepts two parameters:

ParameterTypeDescription
builderStoreobjectThe builder store.
selectorfunction optionalAn optional selector function for extracting specific data from the store. Defaults to (data) => data
comparatorfunction optionalAn optional comparator function used to determine whether the selected data should trigger an update and re-render. Defaults to the built-in shallow comparator.

Returns

The useBuilderStoreData function returns the selected portion of the builder store's data using the provided selector, and triggers a re-render only when the comparator returns false.

Previous
useBuilderStore

Canary Branch