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

Let’s talk

React API Reference

useEntityValueUpdated

The useEntityValueUpdated hook calls the provided callback whenever the value of an entity changes in the given interpreter store.

Reference

useEntityValueUpdated(interpreterStore, callback, comparator?)

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

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

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

  useEntityValueUpdated(interpreterStore, (entity) => {
    console.log(
      `Entity ${entity.id} value changed`,
      "from",
      entity.prevValue,
      "to",
      entity.value,
    );
  });

  return null;
}

Parameters

useEntityValueUpdated accepts three parameters:

ParameterTypeDescription
interpreterStoreobjectThe interpreter store instance to monitor.
callbackfunctionA function called whenever an entity value changes. Receives the updated entity, including value and prevValue.
comparatorfunction optionalOptional comparator used to detect value changes. Defaults to the built-in shallow comparator.

Returns

This hook does not return a value. It registers a side effect that triggers the provided callback whenever an entity's value is updated in the interpreter store.

Previous
useEntityError

Canary Branch