create-react-native-library
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate React Native Library
Create React Native Library 库搭建
Overview
概述
Use this skill to scaffold a standalone React Native library or a local library inside an existing app, then continue with the correct implementation docs.
Examples:
- JS-only library that may use other React Native libraries
- Native modules that expose native functionality to JavaScript
- Native UI components that render native views in React Native
Choose one flow first:
- Use [scaffold-library.md][scaffold-library] when creating a new library that may be published to npm
- Use [local-library.md][local-library] when exposing native functionality in a React Native app
使用本技能可以搭建独立的React Native库,或在现有应用内搭建本地库,之后可参考对应的实现文档继续开发。
示例场景:
- 仅使用JavaScript编写、可能依赖其他React Native库的库
- 向JavaScript暴露原生功能的原生模块
- 在React Native中渲染原生视图的原生UI组件
首先选择一种流程:
- 若要创建可能发布至npm的新库,请参考[scaffold-library.md][scaffold-library]
- 若要在React Native应用中暴露原生功能,请参考[local-library.md][local-library]
When to Apply
适用场景
Use this skill when:
- Creating or working on a React Native library with
create-react-native-library - Creating a native module or view in an existing app
- Wrapping native SDKs and exposing them to React Native
在以下场景中使用本技能:
- 使用创建或开发React Native库
create-react-native-library - 在现有应用中创建原生模块或视图
- 封装原生SDK并向React Native暴露其功能
Quick Reference
快速参考
bash
undefinedbash
undefinedInspect current options before scaffolding
Inspect current options before scaffolding
npx create-react-native-library@latest --help
npx create-react-native-library@latest --help
Scaffold a library with turbo modules and the Expo example app
Scaffold a library with turbo modules and the Expo example app
npx create-react-native-library@latest awesome-library
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
--example expo
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
--example expo
npx create-react-native-library@latest awesome-library
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
--example expo
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
--example expo
Scaffold a local Turbo Module inside an existing app
Scaffold a local Turbo Module inside an existing app
cd MyApp
npx create-react-native-library@latest awesome-library
--local
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
--local
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
undefinedcd MyApp
npx create-react-native-library@latest awesome-library
--local
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
--local
--no-interactive
--yes
--description "A brief description of the library"
--type turbo-module
--languages kotlin-objc
undefinedReferences
参考资料
| File | Description |
|---|---|
| [scaffold-library.md][scaffold-library] | Scaffold a new library and default to the Expo example |
| [local-library.md][local-library] | Add a local library to an existing app with autolinking |
| 文件路径 | 描述 |
|---|---|
| [scaffold-library.md][scaffold-library] | 搭建新库并默认使用Expo示例项目 |
| [local-library.md][local-library] | 向现有应用添加本地库并启用自动链接 |
Problem -> Skill Mapping
问题与技能匹配
| Problem | Start With |
|---|---|
| Need a new library scaffold | scaffold-library |
| Need to add a local native library to an app | local-library |
| 问题 | 起始参考文档 |
|---|---|
| 需要搭建新的库框架 | scaffold-library |
| 需要向应用中添加本地原生库 | local-library |