Effects
Run callbacks when selected form or field state changes.
Effects
useFormEffect(api, selector, callback)
Observes a form, field, or array API. The selector receives its store state; the callback receives the inferred selected value. The hook returns void and cleans up its subscription when the component unmounts or the observed API changes.
The callback runs on subsequent changes that are not deeply equal to the previous selected value. It does not run immediately for the initial value. Unrelated store changes that leave the selection deeply equal do not invoke it.
import { , , } from '@oxform/react';
import { } from 'zod';
function () {
const = ({ : .({ : .() }), : { : '' } });
const = ({ , : 'email' });
(
,
=> .,
=> {
.();
},
);
return null;
}Callbacks may return Promise<void>, but the effect does not await completion before accepting another change. No result or cancellation signal is supplied. Keep the selector and callback stable for a given API: the current hook does not reliably replace an existing subscription when only those function arguments change.
createEffect(api, selector, callback)
The core equivalent has the same selector and callback contract. It returns a subscription with unsubscribe(). Call it to stop future callbacks; it does not cancel a callback already running.
import { , } from '@oxform/core';
import { } from 'zod';
const = ({ : .({ : .() }), : { : '' } });
const = (
,
=> ..,
=> {
.();
},
);
..('email', 'ada@example.com');
.();Signatures
Prop
Type
Prop
Type