Skip to content

Error reasons ​

Methods return {ok: false, reason} instead of throwing.

ReasonReturned byCauseFix
invalid-configpresent, update, replaceEmpty id; unknown variant, presentation, behavior, side or sizing; empty snapPoints; bad appearance value (non-hex colour, out-of-range number); animation value ≤ 0; autoDismissMs ≤ 0; negative margin; non-finite anchor; replace with a different idCheck the values against Appearance and the API
invalid-snap-pointpresent, update, replace, snapToSnap point ≤ 0 or > 100%, duplicate snap points, initialSnapPoint not in snapPoints, or snapTo with a point not in the listSee Snap points
missing-anchorpresentAnchored variant without anchorMeasure the trigger view and pass anchor
duplicate-idpresent, presentNamedA sheet with that id is open (or waiting to replace)Use a different id, or update the existing sheet
not-founddismiss, update, replace, snapTo, expand, collapseNo open sheet with that id (or nothing to dismiss)Check isPresented(id) first, or ignore
stack-limit-reachedpresentmaxStackDepth sheets are already openClose one, use presentation: 'replace', or raise maxStackDepth
replace-in-progresspresent with replaceA previous replace is still waiting for its sheet to closeWait for onDidDismiss, or use update
unknown-sheetpresentNamedThe name isn't registeredRegister it in the SheetRegistry

Errors that throw ​

These are programming errors, so they throw immediately:

MessageCause
useNativeSheet() must be used inside <NativeSheetProvider>.A hook or NativeSheet is rendered outside the provider
maxStackDepth must be an integer >= 1.Invalid maxStackDepth on the provider or SheetManager
Sheet name must be a non-empty string.registry.register('')

Logging failures in development ​

ts
const result = sheet.present(config);
if (__DEV__ && !result.ok) {
  console.warn(`[sheet] ${config.id}: ${result.reason}`);
}

Released under the MIT License.