onChange()

This event handler runs when a field value is changed.

Overview

This is a <Feathery.Form> prop and callback function to run custom logic when a field value is changed. It's called every time the user changes one or multiple field values. This function can be asynchronous.

Usage

You can use onChange to log or update form state when the user modifies it. It 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
    formId='aBcDeF'
    // Custom form step onChange logic
    onChange={(context) => {
      if (context.trigger.id === 'is-it-birthday' && context.fields['is-it-birthday']) {
          showBirthdaySurprise();
      }
    }}
  />
}

Context API

integrationData Definition

If trigger equals addressSelect, this change event was triggered by the user selecting an Address Line 1 dropdown option. In that case, integrationData contains the address's Google Places address ID (id), its individual components, and the latitude / longitude.

triggerData Definition

Last updated