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:
Parameter | Type | Description |
---|---|---|
interpreterStore | object | The interpreter store instance to monitor. |
callback | function | A function called whenever an entity value changes. Receives the updated entity, including value and prevValue . |
comparator | function optional | Optional 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.