goToPreviousPage

API / @publicodes/forms / goToPreviousPage

function goToPreviousPage<RuleName>(formState): FormState<RuleName>

Defined in: form.ts:199

Navigates to the previous page in the form.

Type Parameters

Type ParameterDescription
RuleName extends stringThe existing rule names

Parameters

ParameterTypeDescription
formStateFormState<RuleName>The current state of the form

Returns

FormState<RuleName>

A new form state positioned at the previous page. If already on the first page, returns the original state unchanged

Example

const prevState = goToPreviousPage(formState)
if (prevState === formState) {
  // We were already at the first page
}