Skip to content

ChangeEmailForm

Change the sign-in email; re-authenticated via current password.

import { ChangeEmailForm } from "@evolve-storefront/feature-account/change-email-form";

Renders inside AccountProvider.

Preview

DefaultOpen in Storybook ↗

Usage

const { formProps } = useChangeEmailForm({ onEmailChanged: close });
<ChangeEmailForm {...formProps} onCancel={close} />;

Props

PropTypeDescription
onValidSubmit(values: { email: string; password: string; }) => void
validationBehavior?"aria" | "native"

Default "aria": mark fields via ARIA rather than blocking native submit. The form is then noValidate, so an input's own constraint (type="email") never stops the submit with a browser tooltip that the field's error does not match.

defaultValues?Partial<{ email: string; password: string; }>
isPending?boolean
error?string | null
serverErrors?FormValidationErrors
onCancel?(() => void)

Any other props go to the root element, like on a plain HTML element.

Examples

With ErrorWrong current password (server error surfaced form-level).
// `useChangeEmailForm` maps a wrong current password into formProps.error.
<ChangeEmailForm onValidSubmit={change} error={errorMessage} />;
Open in Storybook ↗