Skip to main content

IRunnerProps interface

📖 Description​

Properties interface for configuring the useRunner hook.

📃 Type declaration​

interface IRunnerProps {
  definition: IDefinition;
  snapshot?: ISnapshot;Optional
  l10nNamespace?: L10n.Namespace;Optional
  view?: "live" | "test" | "preview";Optional
  attachments?: IRunnerAttachments;Optional
  onReady?: (instance?: Instance) => void;EventOptional
  onChange?: (instance: Instance) => void;EventOptional
  onImport?: (instance: Instance) => void;EventOptional
  onData?: (instance: Instance) => void;EventOptional
  onAction?: (
    type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete",
    definition: {
        fingerprint: string;
        name: string;
    },
    block?: {
        id: string;
        name: string;
        alias?: string;
    }
  ) => void;EventOptional
  onSubmit?: (
    instance: Instance,
    language: string,
    locale: string,
    namespace: string | undefined
  ) => Promise<string | undefined> | boolean | void;EventOptional
  onComplete?: (instance: Instance, id?: string) => void;EventOptional
  onDestroy?: () => void;EventOptional
}
🖱ī¸ Hover with the mouse over a property name for a tooltip with the description of that property. Click it for more information.

🗃ī¸ Properties​

🏷ī¸ attachments​

Specifies the attachments handler for processing file uploads.

Type​

IRunnerAttachments


🏷ī¸ definition​

Specifies the form definition to use.

Type​

IDefinition


🏷ī¸ l10nNamespace​

Specifies the l10n namespace to use for translations and locale data.

Type​

L10n.Namespace


🏷ī¸ snapshot​

Specifies the snapshot that should be restored.

Type​

ISnapshot


🏷ī¸ view​

Sets the initial view mode of the runner. It can be one of the following values:

  • live: The form is running in normal (production) mode;
  • test: The form is running in test mode (no response data is submitted);
  • preview: The form is running in preview mode, which shows all blocks in a single view.

Type​

"live" | "test" | "preview"

đŸ“ĸ Events​


🔔 onAction​

Specifies a function that is invoked when the user performs an action. This is useful when you need to implement a tracking service like Google Analytics, Google Tag Manager, or FaceBook Pixel.

tip

Have a look at the Tracking guide to learn more about this feature.

Signature​

(
type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete",
definition: {
fingerprint: string;
name: string;
},
block?: {
id: string;
name: string;
alias?: string;
}
) => void

Parameters​

NameTypeOptionalDescription
type"start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete"NoContains the action type. It can be one of the following values:
- start: A form is started;
- stage: A block gets activated;
- unstage: A block gets deactivated;
- focus: An input element gains focus;
- blur: An input element loses focus;
- pause: A form is paused;
- complete: A form is completed.
definitionobjectNoContains information about the form definition.
blockobject | undefinedYesContains information about the blocks.

🔔 onChange​

Specifies a function that is invoked when there is a change in the runner. This change can be anything from a data update to a UI rendering cycle.

tip

If you only need updates on data changes, use the onData event.

Signature​

(instance: Instance) => void

Parameters​

NameTypeOptionalDescription
instanceInstanceNoReference to the runner instance.

🔔 onComplete​

Specifies a function that is invoked when the runner is completed (after the data is submitted).

Signature​

(instance: Instance, id?: string) => void

Parameters​

NameTypeOptionalDescription
instanceInstanceNoReference to the runner instance.
idstring | undefinedYesContains an optional identifier or reference returned by the server.

🔔 onData​

Specifies a function that is invoked when there is a data change.

Signature​

(instance: Instance) => void

Parameters​

NameTypeOptionalDescription
instanceInstanceNoReference to the runner instance.

🔔 onDestroy​

Specifies a function that is invoked when the component unmounts.

Signature​

() => void

🔔 onImport​

Specifies a function that is invoked when data can be imported into the instance. To import form data, you need to use one of the Import functions from the Runner library as shown in the Prefilling forms guide.

tip

Have a look at the Prefilling forms guide to learn more about importing data.

Signature​

(instance: Instance) => void

Parameters​

NameTypeOptionalDescription
instanceInstanceNoReference to the runner instance.

🔔 onReady​

Specifies a function that is invoked when the runner is ready.

Signature​

(instance: Instance | undefined) => void

Parameters​

NameTypeOptionalDescription
instanceInstance | undefinedNoReference to the runner instance or undefined if no form has started.

🔔 onSubmit​

Specifies a function that is invoked when the runner submits data. This event is the one to use to submit the form data to an endpoint. To retrieve the form data, you need to use one of the Export functions from the Runner library.

This event supports different return types. First of all, you can return a boolean value to indicate if the submission was successful or not. That's only useful for synchronous operations. If you need async operation, you can return a Promise which resolves in case of a successful operation or rejects when the submission fails. The Promise can resolve with an optional string reference.

Signature​

(instance: Instance, language: string, locale: string, namespace: string) =>
Promise<string | undefined> | boolean | void

Parameters​

NameTypeOptionalDescription
instanceInstanceNoReference to the runner instance.
languagestringNoContains the language used in the runner (default is en).
localestringNoContains the locale identifier used in the runner (default is en).
namespacestringNoContains the namespace identifier for the runner.

Return value​

Returns true when the submission succeeded, false if it failed or a Promise that resolves with an optional reference string (in case it succeeds) or rejects (in case of an error).