onLoad()

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.

import { Feathery } from 'feathery-react';
function App() {
// Initialize Feathery to Peter
Feathery.init('adminAPIKey', 'peter@feathery.tech');
// Show the `onboarding` Feathery form
return <Feathery.Form
formKey='onboarding'
// 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 Properties#

KeyTypeDescription
fieldsfieldData objectThe data of all fields in the form.
stepNamestringThe unique ID of the step.
previousStepNameoptional stringThe unique ID of the previous step. null if this is the first step loaded
userIdstringThe unique ID of the current user.
lastStepbooleanTrue when the step being submitted is the last step the user needs to complete.
setValuesfunctionPass in an object of the shape {<fieldKey>: <fieldValue>} to customize internal form state.
setOptionsfunctionPass in an object of the shape {<fieldKey>: [<fieldOption>]} to override the options a user can select for specific fields.
integrationDataobjectThird-party metadata may be passed back through this property. The firebaseAuthId and firebaseAuthToken properties are present when the form is accessed from a Firebase email sign-in link

Return Value#

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