onLoad()

This event handler runs when a step of the form is loaded.

Overview

This is a <Feathery.Form> prop and callback function to run custom logic when a form step is loaded. It's called every time the user loads a step. This function can be asynchronous.

Usage

You can use onLoad to update internal form state, log events, etc. The function takes a single Context object that provides form-related state and handlers.

import { init, Form } from '@feathery/react';

function App() {
  // Initialize Feathery
  init('SDKKey', 'bob@feathery.io');

  // Show the `aBcDeF` Feathery form
  return <Form
    aBcDeF='aBcDeF'
    // Custom form step load logic
    onLoad={(context) => {
      if (context.stepName === 'begin') context.setValues({'beginForm': True});
      else if (context.stepName === 'next-step') logEvent("Loaded Step 2");
    }}
  />
}

Context API

Key
Type
Description

Consistently available form state and functions

Return value

A promise can be optionally returned from this function if it's asynchronous and you want execution to await.

Last updated