Oxform
APISubscribe

Subscribe

Read and render selected form, field, or array state.

Subscribe

Subscribe and useSubscribe accept a form, field, or array API and a selector over its store state. The selector's return type determines the selected value type. Selecting state does not change values, status, or validation.

useSubscribe(api, selector)

Returns the current selected value and subscribes the component to selected state changes. Form selectors receive FormStore; field and array selectors receive their respective stores.

import { , ,  } from '@oxform/react';
import {  } from 'zod';

function () {
  const  = ({ : .({ : .() }), : { : '' } });
  const  = ({ , : 'email' });
  const  = (,  => .);
  const  = (,  => ..);

  return < ={}>{}</>;
}

Subscribe

PropBehavior
apiAPI whose store is observed.
selectorFunction returning the selected value from current state.
childrenRender function receiving that value, or static React children.

The component subscribes through useSubscribe and adds no DOM wrapper.

import { ,  } from '@oxform/react';
import {  } from 'zod';

function () {
  const  = ({ : .({ : .() }), : { : '' } });

  return (
    < ={} ={ => ..}>
      { => (
        < ='submit' ={}>
          Submit
        </>
      )}
    </>
  );
}

Use useFormEffect for a callback when selected state changes, or useFormStatus for all form status properties.

Signatures

Prop

Type

Prop

Type

Prop

Type