onFormStateRestore
Runs when the browser restores the element's state, after back/forward navigation or autofill. For components defined with form-associated.
onFormStateRestore(fn: (state: unknown, mode: string) => void): voidonFormStateRestore((state, mode) => {
editor.text = String(state ?? "");
});Parameters
| Parameter | Type | Meaning |
|---|---|---|
fn |
(state, mode) => void |
Runs from the element's formStateRestoreCallback |
state |
unknown |
The value saved with setFormValue (a string, File, FormData or null) |
mode |
"restore" or "autocomplete" |
Why the state is restored |
When the component declares a value prop, REALM already writes state to it (or sets checked to state !== null when it declares checked) before your hooks run.