createFocusRelay

Creates a focus relay bound to initialTarget

Available since @roku-sdk/navigation 2.19.0

import { createFocusRelay } from "@roku-sdk/navigation/focus-relay";
createFocusRelay(initialTarget: FocusRelayTarget): FocusRelay

Description

Creates a focus relay bound to initialTarget.

Create the relay under a FocusBoundary, and make every target it is later bound to share that boundary's RootFocusBoundary; a nested boundary reads the tree's key-capture state once, when it mounts. The owner of the relayed subtree must call FocusRelay.unbind when the subtree is disposed. The target's boundary drops the relay automatically when it unmounts.

Parameters

NameTypeDescription
initialTargetFocusRelayTargetThe boundary the relay forwards to first, from useFocusRelayTarget.

Return values

A relay to pass to FocusRelayProvider.

Example

const target = useFocusRelayTarget();
const relay = target ? createFocusRelay(target) : null;
if (relay) onCleanup(() => relay.unbind());

Did this page help you?