as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
跳转到主要内容
The FocusManager module provides custom focus management functionality based on You.i TV’s module. This module aims to provide a way for you to change the way focus transitions occur between components, as compared to the default behavior in React Native. The APIs are imperative in nature as they help app developers separate business logic from layout logic.

Example usage

The following example is adapted from the You.i focus-management example code on GitHub.

Methods

getFocused()

Retrieves the tag of the current focused component.

setNextFocus()

Sets the next focus in the specified direction, from the component indicated by fromTag to the component indicated by toTag. The list of possible directions is as follows:

clearNextFocus()

Clears any focus overrides created by setNextFocus starting from the component indicated by fromTag.

setFocusRoot()

Sets whether focus can leave the component indicated by fromTag and its children.

focus()

Brings the component indicated by tag into focus.

blur()

Removes the component indicated by tag from focus.

Known issues

  • Calling these APIs from the useEffect hook can fail the first time that the component is mounted. This occurs due to a known issue in Vega where useEffect can execute earlier than expected. You can work around this issue by adding a timeout/delay to your useEffect logic.
  • tag* parameters of the api accept either ref or the tag of the component. However, there is an issue with typechecking if a ref is used directly. Please use findNodeHandle as shown in example to resolve type related issues.

See Also


最后修改于 2026年10月26日