Community编程与开发github.com

react-native-tv-best-practices

审查 React Native TV 应用的焦点/D-pad 导航、10 英尺 UI 布局、电视播放/DRM 集成、低内存电视性能以及电视可访问性。适用于构建、调试或审查 react-native-tvos、Expo TV、Amazon Vega/Kepler 或 React Native Web TV 目标,且问题与遥控输入、电视焦点、电视打包、电视硬件或电视播放限制相关。

react-native-tv-best-practices 是什么?

本技能为基于 React Native 的 Apple TV、Android TV、Fire TV、Amazon Vega/Kepler 以及 Tizen/webOS 等 Web 电视目标的电视特定审查提供全面指导。它专注于电视独有的差异,如遥控/D-pad 输入、焦点引擎、10 英尺 UI 布局、平台打包、视频播放与 DRM、低内存电视硬件优化以及屏幕阅读器可访问性。技能通过按主题分组的参考文件(如 `focus-*`、`nav-*`、`design-*`、`perf-*`、`video-*`、`a11y-*` 等)组织了详细的审查规则和优先级排序的指南,帮助开发者从 setup/build 配置到播放调试和性能优化逐步排查问题。它支持所有主流电视堆栈,并特别强调在给出设置建议前先检测目标堆栈,以避免误报。适用于 react-native-tvos、Expo TV、Amazon Vega/Kepler 以及 Tizen/webOS 项目,帮助团队在电视应用开发中快速定位和解决关键问题。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/callstackincubator/agent-skills/tree/main/skills/react-native-tv-best-practices

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

React Native TV 最佳实践

概述

针对 Apple TV、Android TV、Fire TV、Amazon Vega/Kepler 以及 Tizen 或 webOS 等 Web 电视目标的 React Native 应用的电视特定审查指导。

仅在涉及电视差异时使用此技能:遥控输入、焦点引擎、10 英尺布局、平台打包、播放/DRM、低内存电视硬件以及电视可访问性。对于普通的 React Native 性能或架构问题,请使用 react-native-best-practices。

技能格式

参考文件按主题前缀分组:

  • focus-*:焦点引擎、焦点指南、焦点事件性能
  • nav-*:D-pad 导航、返回/菜单行为、键盘/搜索输入
  • design-*:10 英尺排版、布局、色彩、焦点可见性
  • perf-*:启动、内存、列表、动画以及在电视硬件上的网络约束
  • video-*:播放架构、DRM/协议选择、调试
  • a11y-*:电视可访问性实现和审计检查
  • setup-*:堆栈检测、设置、架构、跨平台行为
  • test-* 和 release-*:测试覆盖率、端到端测试以及 CI/发布工作流

何时应用

当应用针对电视平台且工作涉及以下内容时,应用此技能:

  • 焦点移动、可见焦点、焦点恢复或遥控/D-pad 输入
  • 电视布局可读性、过扫描/安全区域或 10 英尺 UI 密度
  • 电视播放器控件、清单、DRM、解码器支持或播放错误
  • 低内存电视硬件上的性能,尤其是涉及视频或大型轮播时
  • 使用屏幕阅读器、字幕、焦点顺序或仅遥控交互的电视可访问性
  • react-native-tvos、Expo TV、Amazon Vega/Kepler、Tizen 或 webOS 的平台设置

开始前 — 识别电视堆栈

本技能涵盖多个电视堆栈。在标记设置问题前,先检测应用针对的是哪个堆栈 — 在 Vega/Kepler 或基于 Web 的电视应用上要求 react-native-tvos、tvOS Podfile 或 Android TV 清单会产生误报。

堆栈如何检测设置期望
react-native-tvos (Apple TV, Android TV, Fire TV)在 package.json 中 "react-native": "npm:react-native-tvos@…"tvOS Podfile (platform :tvos);Android TV leanback/LEANBACK_LAUNCHER 清单条目;电视模拟器/仿真器
Expo + react-native-tvos以上条件 加上 在 app.json 中的 @react-native-tvos/config-tvEXPO_TV=1 预构建;react-native-tvos 版本必须与 Expo SDK 匹配;并非所有 Expo 特性/库在电视上可用
Amazon Vega / KeplerVega/Kepler SDK 和工具链(@amazon-devices/* 依赖、Kepler 清单);不包含 react-native-tvosAmazon 的 Vega/Kepler 工具链 — react-native-tvos、tvOS Podfile 和 Android TV 清单 不适用
基于 Web 的电视 (Tizen, webOS)Web 打包工具(Rsbuild/webpack)+ 平台打包;spatial-nav 库平台 SDK 打包;使用 @noriginmedia/norigin-spatial-navigation 处理焦点

焦点、10 英尺设计、性能、可访问性和播放器指导适用于所有这些堆栈 — 只有 设置/构建 期望是堆栈特定的。

审查规则

  • 在给出设置建议前,先确定目标堆栈。
  • 优先使用自然焦点顺序和焦点指南,而不是命令式焦点调用或广泛的 nextFocus* 映射。
  • 将焦点丢失、焦点不可见以及返回/菜单行为异常视为导航错误。
  • 在调整视觉细节前,先检查电视距离下的可读性、安全区域和焦点状态。
  • 在报告性能修复完成前,先在支持的最弱电视设备上进行性能分析。
  • 按层级分离播放失败:清单请求、DRM 许可证交换、解码器能力、播放器状态和 React UI 控件。

优先级排序指南

优先级类别影响前缀
1焦点和 D-pad 导航关键focus-*、nav-*
2列表、动画和输入性能关键perf-*
3播放和 DRM 失败高video-*
410 英尺可读性和布局高design-*
5电视可访问性高a11y-*
6堆栈设置、测试和发布中setup-*、test-*、release-*

快速参考

  1. 从包文件、清单、原生文件夹和平台工具中检测电视堆栈。
  2. 使用遥控或 D-pad 路径(而非鼠标/触摸假设)复现导航。
  3. 确认焦点元素始终可见、可到达,并在模态框/路由后恢复。
  4. 在更改 React 控件之前,先从网络/DRM 层向上检查播放失败。
  5. 在支持的最弱电视目标上测量列表、动画、内存和启动工作。

参考

焦点和导航

文件影响描述
focus-management.md关键焦点引擎、焦点指南、nextFocus* 和焦点恢复
focus-performance.md关键避免因焦点事件处理导致的帧丢失
nav-directional.md关键跨电视平台的定向导航规则
nav-patterns.md关键全局/局部导航、模态框、选项卡和返回行为
nav-keyboard.md中使用遥控器进行搜索和文本输入

设计

文件影响描述
design-10foot.md高10 英尺审查启发式方法
design-typography.md高电视字体大小和可读性
design-layout.md高安全区域、间距、轮播和焦点空间
design-color.md中对比度和电视显示色彩约束

性能

文件影响描述
perf-overview.md高电视性能目标和性能分析顺序
perf-lists.md关键虚拟化行和海报密集型列表
perf-animations.md关键焦点和过渡动画性能
perf-memory.md高低内存电视崩溃和图像/视频压力
perf-network.md高遥控输入、请求停滞和网络弹性

视频、可访问性、设置、测试

文件影响描述
video-streaming.md高电视平台协议/DRM 选择
video-players.md高播放器选择和自定义控件
video-debugging.md高清单、DRM、编解码器和播放调试
a11y-overview.md中电视特定的可访问性差异
a11y-implementation.md高可访问标签、角色、活动区域和焦点
a11y-checklist.md中发布可访问性审计清单
setup-getting-started.md中react-native-tvos 和 Expo TV 设置
setup-cross-platform.md中平台检测和跨平台注意事项
setup-architecture.md中代码共享和项目结构
test-strategy.md中电视测试范围和覆盖率划分
test-javascript.md中JS 层遥控/焦点测试辅助工具
test-e2e.md中Appium 和电视端到端测试覆盖率
release-cicd.md中CI、构建指纹识别和发布检查

问题 → 技能映射

症状从这里开始
"焦点跳到错误元素"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 → 内置 vs 自定义
"应用启动非常慢"perf-overview.md → 启动时间
"图像导致内存崩溃"perf-memory.md → 图像优化
"CI 流水线需要数小时"release-cicd.md → 指纹识别
"如何在平台间共享代码"setup-architecture.md → 代码共享

安全(电视特定)

与任何 RN 应用一样,通用的依赖/输入卫生规则适用;以下是值得指出的电视特定差异:

  • 切勿将 FairPlay/Widevine/PlayReady 密钥嵌入客户端代码 — 将许可证服务器视为信任边界,并保持 DRM 令牌由服务器颁发。

Individual skills in this repo

This repo contains 15 individual skills — each has its own dedicated page.

agent-device

Automates interactions for Apple-platform apps (iOS, tvOS, macOS) and Android devices. Use when navigating apps, taking snapshots/screenshots, tapping, typing, scrolling, or extracting UI info across mobile, TV, and desktop targets.

assess-react-native-migration

Assesses whether and how an existing mobile product should migrate to React Native. Use when auditing one or more product repositories for migration readiness, including products whose iOS, Android, and other clients live in separate directories or repositories; choosing brownfield, greenfield, or a checkpoint-based path; defining a representative trial; or preparing a baseline and ROI decision before implementation. When product scope or material evidence is unavailable, grills the stakeholder with exactly one question per turn instead of sending a questionnaire.

callstackincubator/github

GitHub patterns using gh CLI for pull requests, stacked PRs, code review, branching strategies, and repository automation. Use when working with GitHub PRs, merging strategies, or repository management tasks.

callstackincubator/validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

create-react-native-library

Scaffolds React Native libraries with create-react-native-library for standalone libraries or local native modules and views. Use when creating or working on React Native libraries or adding native functionality in an existing app.

dogfood

Systematically explore and test a mobile app on iOS/Android with agent-device to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", or "test this app" on mobile. Produces a structured report with reproducible evidence: screenshots, optional repro videos, and detailed steps for every issue.

github-actions

GitHub Actions workflow patterns for React Native iOS simulator and Android emulator cloud builds with downloadable artifacts. Use when setting up CI build pipelines or downloading GitHub Actions artifacts via gh CLI and GitHub API.

react-native-best-practices

Provides React Native performance optimization guidelines for FPS, TTI, bundle size, memory leaks, re-renders, and animations. Applies to tasks involving Hermes optimization, JS thread blocking, bridge overhead, FlashList, native modules, or debugging jank and frame drops.

react-native-brownfield-migration

Implements an accepted incremental brownfield migration from native iOS or Android to React Native or Expo using @callstack/react-native-brownfield. Use after the brownfield path has been selected, when setting up the integration, packaging XCFramework or AAR artifacts, or adding React Native surfaces to native hosts.

react-native-testing

Write tests using React Native Testing Library (RNTL) v13 and v14 (`@testing-library/react-native`). Use when writing, reviewing, or fixing React Native component tests. Covers: render, screen, queries (getBy/getAllBy/queryBy/findBy), Jest matchers, userEvent, fireEvent, waitFor, and async patterns. Supports v13 (React 18, sync render) and v14 (React 19+, async render). Triggers on: test files for React Native components, RNTL imports, mentions of "testing library", "write tests", "component tests", or "RNTL".

react-navigation

Provides React Navigation UI patterns for stacks, tabs, drawers etc. Use when building navigation UIs with React Navigation, configuring headers, bottom sheets or handling safe areas and insets.

upgrading-react-native

Upgrades React Native apps to newer versions by applying rn-diff-purge template diffs, updating package.json dependencies, migrating native iOS and Android configuration, resolving CocoaPods and Gradle changes, and handling breaking API updates. Use when upgrading React Native, bumping RN version, updating from RN 0.x to 0.y, or migrating Expo SDK alongside a React Native upgrade.

validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

writing-user-docs

House style for user-facing documentation — voice, scope, structure, and what to leave out. Use this skill whenever writing, editing, or reviewing anything a user reads to learn how to use a tool — help center articles, getting-started guides, tutorials, feature docs, README usage sections, in-app help, release notes, or FAQ entries. Trigger it even when the request is phrased plainly — "document this feature", "write docs for X", "explain this to users", "write a README for this library", "turn these notes into a guide" — and even when no style guidelines are mentioned. Also use it to review existing docs for tone, bloat, or leaked implementation detail. Do not use it for internal engineering docs, architecture write-ups, RFCs, or code comments.

相关技能