react-native-tv-best-practices
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReact Native TV Best Practices
React Native TV 最佳实践
Overview
概述
TV-specific review guidance for React Native-backed apps on Apple TV, Android TV, Fire TV, Amazon Vega/Kepler, and web-based TV targets such as Tizen or webOS.
Use this skill only for TV deltas: remote input, focus engines, 10-foot layout, platform packaging, playback/DRM, low-memory TV hardware, and TV accessibility. For ordinary React Native performance or architecture issues, use react-native-best-practices.
针对基于React Native的Apple TV、Android TV、Fire TV、Amazon Vega/Kepler以及基于网页的电视平台(如Tizen或webOS)应用的专属评审指南。
仅在涉及电视特有差异的场景下使用本技能:遥控器输入、焦点引擎、10英尺布局、平台打包、播放/DRM、低内存电视硬件以及电视可访问性。对于普通React Native性能或架构问题,请使用react-native-best-practices。
Skill Format
技能格式
Reference files are grouped by topic prefix:
- : focus engines, focus guides, focus event performance
focus-* - : D-pad navigation, Back/Menu behavior, keyboard/search input
nav-* - : 10-foot typography, layout, color, focus visibility
design-* - : startup, memory, lists, animation, and network constraints on TV hardware
perf-* - : playback architecture, DRM/protocol selection, debugging
video-* - : TV accessibility implementation and audit checks
a11y-* - : stack detection, setup, architecture, cross-platform behavior
setup-* - and
test-*: test coverage, E2E, and CI/release workflowsrelease-*
参考文件按主题前缀分组:
- :焦点引擎、焦点引导、焦点事件性能
focus-* - :方向键导航、返回/菜单行为、键盘/搜索输入
nav-* - :10英尺排版、布局、颜色、焦点可见性
design-* - :电视硬件上的启动、内存、列表、动画及网络限制
perf-* - :播放架构、DRM/协议选择、调试
video-* - :电视可访问性实现及审计检查
a11y-* - :技术栈检测、配置、架构、跨平台行为
setup-* - 和
test-*:测试覆盖、端到端测试、CI/发布流程release-*
When to Apply
适用场景
Apply this skill when the app targets a TV platform and the work involves:
- Focus movement, visible focus, focus restoration, or remote/D-pad input
- TV layout readability, overscan/safe areas, or 10-foot UI density
- TV player controls, manifests, DRM, decoder support, or playback errors
- Performance on low-memory TV hardware, especially with video or large carousels
- TV accessibility with screen readers, captions, focus order, or remote-only interaction
- Platform setup for , Expo TV, Amazon Vega/Kepler, Tizen, or webOS
react-native-tvos
当应用目标为电视平台且工作涉及以下内容时,应用本技能:
- 焦点移动、焦点可见性、焦点恢复或遥控器/方向键输入
- 电视布局可读性、过扫描/安全区域或10英尺UI密度
- 电视播放器控件、清单、DRM、解码器支持或播放错误
- 低内存电视硬件上的性能,尤其是涉及视频或大型轮播组件时
- 带屏幕阅读器、字幕、焦点顺序或仅遥控器交互的电视可访问性
- 、Expo TV、Amazon Vega/Kepler、Tizen或webOS的平台配置
react-native-tvos
Before You Start — Identify the TV Stack
开始前——识别电视技术栈
This skill covers several TV stacks. Detect which one the app targets before flagging setup issues — demanding , a tvOS Podfile, or an Android TV manifest on a Vega/Kepler or web-based TV app produces false positives.
react-native-tvos| Stack | How to detect | Setup expectations |
|---|---|---|
| react-native-tvos (Apple TV, Android TV, Fire TV) | | tvOS Podfile ( |
| Expo + react-native-tvos | above plus | |
| Amazon Vega / Kepler | Vega/Kepler SDK & tooling ( | Amazon's Vega/Kepler toolchain — |
| Web-based TV (Tizen, webOS) | web bundler (Rsbuild/webpack) + platform packaging; spatial-nav library | Platform SDK packaging; |
The focus, 10-foot design, performance, accessibility, and player guidance applies across all of these — only the setup/build expectations are stack-specific.
本技能覆盖多种电视技术栈。在标记配置问题前,先检测应用目标技术栈——在Vega/Kepler或网页端电视应用中要求使用、tvOS Podfile或Android TV清单文件会产生误报。
react-native-tvos| 技术栈 | 检测方式 | 配置预期 |
|---|---|---|
| react-native-tvos(Apple TV、Android TV、Fire TV) | package.json 中存在 | tvOS Podfile( |
| Expo + react-native-tvos | 满足上述条件,且app.json中包含 | 执行 |
| Amazon Vega / Kepler | 使用Vega/Kepler SDK及工具(依赖 | 使用Amazon的Vega/Kepler工具链—— |
| 网页端电视(Tizen、webOS) | 使用网页打包工具(Rsbuild/webpack)+ 平台打包工具;包含空间导航库 | 平台SDK打包;使用 |
焦点、10英尺设计、性能、可访问性及播放器指南适用于所有这些技术栈——仅配置/构建预期因技术栈而异。
Review Rules
评审规则
- Resolve the target stack before setup advice.
- Prefer natural focus order and focus guides before imperative focus calls or broad maps.
nextFocus* - Treat focus loss, invisible focus, and broken Back/Menu behavior as navigation bugs.
- Check readability, safe areas, and focus states at TV distance before tuning visual details.
- Profile on the weakest supported TV device before reporting performance fixes as complete.
- Separate playback failures by layer: manifest request, DRM license exchange, decoder capability, player state, and React UI controls.
- 给出配置建议前先明确目标技术栈。
- 优先使用自然焦点顺序和焦点引导,而非强制焦点调用或宽泛的映射。
nextFocus* - 将焦点丢失、焦点不可见及返回/菜单行为异常视为导航Bug。
- 在调整视觉细节前,先检查电视距离下的可读性、安全区域和焦点状态。
- 在报告性能修复完成前,先在最弱的支持电视设备上进行性能分析。
- 按层级区分播放故障:清单请求、DRM许可证交换、解码器能力、播放器状态及React UI控件。
Priority-Ordered Guidelines
优先级排序指南
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Focus and D-pad navigation | CRITICAL | |
| 2 | List, animation, and input performance | CRITICAL | |
| 3 | Playback and DRM failures | HIGH | |
| 4 | 10-foot readability and layout | HIGH | |
| 5 | TV accessibility | HIGH | |
| 6 | Stack setup, testing, and release | MEDIUM | |
| 优先级 | 分类 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 焦点与方向键导航 | 关键 | |
| 2 | 列表、动画与输入性能 | 关键 | |
| 3 | 播放与DRM故障 | 高 | |
| 4 | 10英尺可读性与布局 | 高 | |
| 5 | 电视可访问性 | 高 | |
| 6 | 技术栈配置、测试与发布 | 中 | |
Quick Reference
快速参考
- Detect the TV stack from package files, manifests, native folders, and platform tooling.
- Reproduce navigation with the remote or D-pad path, not mouse/touch assumptions.
- Confirm the focused element is always visible, reachable, and restored after modals/routes.
- Check playback failures from the network/DRM layer upward before changing React controls.
- Measure list, animation, memory, and startup work on the weakest supported TV target.
- 从包文件、清单文件、原生文件夹及平台工具中检测电视技术栈。
- 使用遥控器或方向键路径复现导航问题,而非基于鼠标/触摸的假设。
- 确认聚焦元素始终可见、可访问,且在模态框/路由切换后能恢复焦点。
- 在修改React控件前,先从网络/DRM层向上排查播放故障。
- 在最弱的支持电视目标设备上测试列表、动画、内存及启动性能。
References
参考资料
Focus and Navigation
焦点与导航
| File | Impact | Description |
|---|---|---|
| focus-management.md | CRITICAL | Focus engines, focus guides, |
| focus-performance.md | CRITICAL | Avoiding frame drops from focus event handling |
| nav-directional.md | CRITICAL | Directional navigation rules across TV platforms |
| nav-patterns.md | CRITICAL | Global/local navigation, modals, tabs, and Back behavior |
| nav-keyboard.md | MEDIUM | Search and text input with remotes |
| 文件 | 影响程度 | 描述 |
|---|---|---|
| focus-management.md | 关键 | 焦点引擎、焦点引导、 |
| focus-performance.md | 关键 | 避免焦点事件处理导致的掉帧 |
| nav-directional.md | 关键 | 跨电视平台的方向导航规则 |
| nav-patterns.md | 关键 | 全局/局部导航、模态框、标签页及返回行为 |
| nav-keyboard.md | 中 | 使用遥控器进行搜索和文本输入 |
Design
设计
| File | Impact | Description |
|---|---|---|
| design-10foot.md | HIGH | 10-foot review heuristics |
| design-typography.md | HIGH | TV type sizing and readability |
| design-layout.md | HIGH | Safe areas, spacing, carousels, and focus room |
| design-color.md | MEDIUM | Contrast and TV display color constraints |
| 文件 | 影响程度 | 描述 |
|---|---|---|
| design-10foot.md | 高 | 10英尺评审启发式规则 |
| design-typography.md | 高 | 电视字体大小与可读性 |
| design-layout.md | 高 | 安全区域、间距、轮播组件及焦点空间 |
| design-color.md | 中 | 对比度与电视显示颜色限制 |
Performance
性能
| File | Impact | Description |
|---|---|---|
| perf-overview.md | HIGH | TV performance targets and profiling order |
| perf-lists.md | CRITICAL | Virtualized rows and poster-heavy lists |
| perf-animations.md | CRITICAL | Focus and transition animation performance |
| perf-memory.md | HIGH | Low-memory TV crashes and image/video pressure |
| perf-network.md | HIGH | Remote input, request stalls, and network resilience |
| 文件 | 影响程度 | 描述 |
|---|---|---|
| perf-overview.md | 高 | 电视性能目标与分析顺序 |
| perf-lists.md | 关键 | 虚拟化行与海报密集型列表 |
| perf-animations.md | 关键 | 焦点与过渡动画性能 |
| perf-memory.md | 高 | 低内存电视崩溃及图片/视频内存压力 |
| perf-network.md | 高 | 遥控器输入、请求停滞及网络韧性 |
Video, Accessibility, Setup, Testing
视频、可访问性、配置、测试
| File | Impact | Description |
|---|---|---|
| video-streaming.md | HIGH | TV platform protocol/DRM selection |
| video-players.md | HIGH | Player choices and custom controls |
| video-debugging.md | HIGH | Manifest, DRM, codec, and playback debugging |
| a11y-overview.md | MEDIUM | TV-specific accessibility differences |
| a11y-implementation.md | HIGH | Accessible labels, roles, live regions, and focus |
| a11y-checklist.md | MEDIUM | Launch accessibility audit checklist |
| setup-getting-started.md | MEDIUM | |
| setup-cross-platform.md | MEDIUM | Platform detection and cross-platform caveats |
| setup-architecture.md | MEDIUM | Code sharing and project structure |
| test-strategy.md | MEDIUM | TV testing scope and coverage split |
| test-javascript.md | MEDIUM | JS-level remote/focus test helpers |
| test-e2e.md | MEDIUM | Appium and TV E2E coverage |
| release-cicd.md | MEDIUM | CI, build fingerprinting, and release checks |
| 文件 | 影响程度 | 描述 |
|---|---|---|
| video-streaming.md | 高 | 电视平台协议/DRM选择 |
| video-players.md | 高 | 播放器选择与自定义控件 |
| video-debugging.md | 高 | 清单、DRM、编解码器及播放调试 |
| a11y-overview.md | 中 | 电视专属可访问性差异 |
| a11y-implementation.md | 高 | 可访问标签、角色、实时区域及焦点 |
| a11y-checklist.md | 中 | 发布可访问性审计清单 |
| setup-getting-started.md | 中 | |
| setup-cross-platform.md | 中 | 平台检测与跨平台注意事项 |
| setup-architecture.md | 中 | 代码共享与项目结构 |
| test-strategy.md | 中 | 电视测试范围与覆盖划分 |
| test-javascript.md | 中 | JS层遥控器/焦点测试工具 |
| test-e2e.md | 中 | Appium与电视端到端测试覆盖 |
| release-cicd.md | 中 | CI、构建指纹及发布检查 |
Problem → Skill Mapping
问题→技能映射
| Symptom | Start Here |
|---|---|
| "Focus jumps to wrong element" | focus-management.md → Debugging section |
| "App freezes when scrolling lists" | perf-lists.md → Virtualization |
| "Animations stutter on Fire TV" | perf-animations.md → Native driver |
| "Text too small on TV" | design-typography.md → Minimum sizes |
| "Video won't play / DRM errors" | video-streaming.md → DRM section |
| "Screen reader skips elements" | a11y-implementation.md → Roles & labels |
| "Back button doesn't work right" | nav-patterns.md → Back navigation |
| "Keyboard covers content" | nav-keyboard.md → Built-in vs custom |
| "App takes forever to start" | perf-overview.md → Startup time |
| "Images causing memory crashes" | perf-memory.md → Image optimization |
| "CI pipeline takes hours" | release-cicd.md → Fingerprinting |
| "How to share code across platforms" | setup-architecture.md → Code sharing |
| 症状 | 起始参考文档 |
|---|---|
| "焦点跳转到错误元素" | focus-management.md → 调试章节 |
| "滚动列表时应用冻结" | perf-lists.md → 虚拟化 |
| "Fire TV上动画卡顿" | perf-animations.md → 原生驱动 |
| "电视上文本过小" | design-typography.md → 最小尺寸 |
| "视频无法播放/DRM错误" | video-streaming.md → DRM章节 |
| "屏幕阅读器跳过元素" | a11y-implementation.md → 角色与标签 |
| "返回按钮工作异常" | nav-patterns.md → 返回导航 |
| "键盘遮挡内容" | nav-keyboard.md → 内置与自定义 |
| "应用启动耗时过长" | perf-overview.md → 启动时间 |
| "图片导致内存崩溃" | perf-memory.md → 图片优化 |
| "CI流水线耗时数小时" | release-cicd.md → 构建指纹 |
| "如何跨平台共享代码" | setup-architecture.md → 代码共享 |
Security (TV-Specific)
安全(电视专属)
General dependency/input hygiene applies as in any RN app; the TV-specific deltas worth calling out:
- Never embed FairPlay/Widevine/PlayReady keys in client code — treat the license server as the trust boundary and keep DRM tokens server-issued.
通用依赖/输入安全规范适用于所有RN应用;以下是需要特别注意的电视专属差异:
- 切勿在客户端代码中嵌入FairPlay/Widevine/PlayReady密钥——将许可证服务器视为信任边界,保持DRM令牌由服务器颁发。",