Expo UI and Router for iOSExpo SDK 57 and later, iOS only
Modifiers

onAppear

Adds an onAppear modifier that calls a function when the view appears.

onAppear(handler)

ParameterTypeDescription
handler() => voidFunction to call when the view appears.

Adds an onAppear modifier that calls a function when the view appears.

Returns: ModifierConfig

See: Official SwiftUI documentation.

Works with

You can add onAppear to any view. It changes what you see on 33 of the 39 components.

Needs care

It works on these components, but not in the way that you may expect.

ComponentWhat to know
BottomSheetRuns for the anchor, not for the sheet. To know when the sheet opens, put it on a view in the sheet content.
AlertRuns for the trigger, not for the alert.
ConfirmationDialogRuns for the trigger, not for the dialog.
PopoverRuns for the trigger, not for the popover. To know when the popover opens, put it on a view in Popover.Content.
TabViewRuns for the whole tab view, not for one tab. Put it on the content of a tab.

No visible effect

These components accept it, but you see no change.

ComponentWhy nothing happens
SpacerIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
DividerIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
SliderIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
MenuIn SDK 57, Menu does not send modifier events to JavaScript, so the handler does not run.
ContextMenuIn SDK 57, ContextMenu does not send modifier events to JavaScript, so the handler does not run.
AccessoryWidgetBackgroundIn SDK 57, AccessoryWidgetBackground does not send modifier events to JavaScript, so the handler does not run.

Sources

The original Expo docs for this page:

On this page