React Nitro

ViewControllerContext

Provide the native view controller that hosts a React subtree.

App.tsx
<ViewControllerContext.Provider  value={appController}>  <HostReadout /></ViewControllerContext.Provider>// Inside HostReadout:const host = useRootContext()
Screen host
Nearest controllerApp
Switch the host of the same readout. It reads the controller supplied by its nearest provider.

The renderer supplies this React context at the root, and navigation supplies it again for each screen. Inside a screen, useRootContext() reads the nearest controller and useSafeAreaInsets() subscribes to its safe area.

Use the provider when implementing a host that already owns a native controller. Set value to the controller that actually hosts the children.

import type { ReactNode } from 'react'
import { ViewControllerContext, type ViewController } from 'react-nitro-renderer'

export function ScreenScope({ controller, children }: { controller: ViewController; children: ReactNode }) {
  return <ViewControllerContext.Provider value={controller}>{children}</ViewControllerContext.Provider>
}

Providing the context makes the controller available to descendants. The host manages the controller's native view hierarchy. Layout and safe areas