Promise-based API
Both Surface.Dialog.present() and Surface.Sheet.present() return a Promise.
const value = await Surface.Dialog.present<Result>({
body: MyDialog,
});The Promise remains pending while the surface is open.
Resolving the Promise
The body receives:
interface SurfaceContext<T = any> {
pop: (value?: T | null) => void;
props?: any;
}Call pop() to resolve without a value:
pop();Call pop(value) to return a value:
pop({
id: user.id,
name: user.name,
});Cancellation
A dismissed surface resolves with undefined when it is closed through the default backdrop dismissal.
You can also explicitly return null:
pop(null);This lets your application distinguish between different outcomes if needed.
Example
const choice = await Surface.Sheet.present<'camera' | 'gallery'>({
body: ({ pop }) => (
<>
<button onClick={() => pop('camera')}>Camera</button>
<button onClick={() => pop('gallery')}>Gallery</button>
</>
),
});
if (choice === 'camera') {
openCamera();
}