Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ReactNative 探索之路
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
David Zhang
September 02, 2016
Programming
380
1
Share
ReactNative 探索之路
来自 Dengxi (@regrex)
David Zhang
September 02, 2016
More Decks by David Zhang
See All by David Zhang
ngx_share: conf & module
crispgm
0
27
Nginx 事件驱动机制
crispgm
0
560
Other Decks in Programming
See All in Programming
脱 雰囲気実装!AgentCoreを良い感じにWEBアプリケーションに組み込むために
takuyay0ne
3
440
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
290
The free-lunch guide to idea circularity
hollycummins
0
410
我々はなぜ「層」を分けるのか〜「関心の分離」と「抽象化」で手に入れる変更に強いシンプルな設計〜 #phperkaigi / PHPerKaigi 2026
shogogg
2
800
Feature Toggle は捨てやすく使おう
gennei
0
420
へんな働き方
yusukebe
6
2.9k
存在論的プログラミング: 時間と存在を記述する
koriym
5
780
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
230
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
1
320
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
830
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
140
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
310
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.7k
GraphQLとの向き合い方2022年版
quramy
50
14k
Bash Introduction
62gerente
615
210k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.4k
How to make the Groovebox
asonas
2
2.1k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
410
Facilitating Awesome Meetings
lara
57
6.8k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
880
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
160
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
500
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Balancing Empowerment & Direction
lara
5
1k
Transcript
React Native探索之路
[email protected]
Content • React Native ᓌՕ • ᭌೠReact NativeҘ • ই֜ଫአReact
NativeҘ • Demoᄍᐏ • ᷚᴾ݊
React Native简介 • 概览 • 开发环境 • 技术构成 • 社区生态
React Native概览 LEARN ONCE, WRITE ANYWHERE BUILD MOBILE APPS WITH
REACT Shared JS Logic Code React Component React Virtual DOM System Layout Compiler & RTC Bridge Android Native UI iOS Native UI
React Native开发环境
React Native技术构成 • 基本元素 • UI更新逻辑 • 通信机制 • 布局机制
React Native基本元素 ListView View ScrollView TextInput TouchableHighlight … UITableView UIView
UIScrollView UITextField UIButton … React Native lib Cocoa Touch
React Native UI更新逻辑 React DOM diff算法
React Native通信机制 React Native Native • OC᭗ᬦRCT_CUSTOM_VIEW_PROPERTYਡูᶂંکRNጱprops᯾ • OC᭗ᬦRCT_EXPORT_MODULERCT_EXPORT_METHODਡูᶂᕳRN᯾ •
Java᭗ᬦ@ReactProp@ReactPropGroupဳ᯽ڊંጱsetොဩ׀RN • Native᭗ᬦRTCBridge׀ጱJSཛྷࣘොဩፗളᦢᳯ • ᭗ᬦRCTEventDispatcherզݎᭆളතၾ௳ጱොୗਫሿ᧣አҁJSጱߥଫࢧ᧣ڍහ҂ React Native᭗מګᧇᥴ 模块化、模块配置表、传递ID、封装调用、事件响应
Flex box Flex Container Flex Item Flex Item Flex Item
Cross Axis Main Axis Cross Size Main Size Autolayout React Native布局机制 Cross Start Cross End Main Start Main End
React Native社区生态 • 社区活跃度 • 谁在用React Native
React Native社区活跃度 • star: 37k+ • fork: 8k+ • component:
500+ https://js.coach/react-native React Native: A year in review
谁在用React Native Apps: 100+ showcase
Content • React Native ᓌՕ • ᭌೠReact NativeҘ • ই֜ଫአReact
NativeҘ • Demoᄍᐏ • ᷚᴾ݊
选择React Native? • 开发成本 • 对比其他方案 • 医疗业务应用场景
React Native开发成本 RN ≈ (Android + iOS + Web) /
2 ӣොᦡᦇӞᛘ
对比其他方案 H5、React Native、Native应用对比分析
医疗业务应用场景 • App中频繁迭代部分:如医疗服务 • 新App开发:如医院版
Content • React Native ᓌՕ • ᭌೠReact NativeҘ • ই֜ଫአReact
NativeҘ • Demoᄍᐏ • ᷚᴾ݊
如何应用React Native • 开发 • 联调 • 测试 • 发布
开发 • 环境搭建 • 知识储备 • 代码调试
联调 • 与server联调 • 植入原生应用
与server联调 比XMLHttpRequest更先进的WebAPI,支持Promise fetch('http://api.baidu.com/path?params') // web api .then( response => response.json()
) .then( json => { // ྋଉߥଫ॒ቘ᭦ᬋ }) .catch(error => // ଉ॒ቘ᭦ᬋ );
植入原生应用 1. 通过CocoaPods安装React Native 2. 创建继承自UIView的ReactView应用类 3. 通过RN的index.ios.bundle来初始化RCTRootView 4. 添加ReactView为rootView的子视图
5. 更新App Transport Security(http支持) 6. 编译运行 iOS
植入原生应用 1. build.gradle添加React Native依赖 2. 创建实现ReactRootView的原生Activity 3. 获取index.android.bundle文件 4. 关联index.android.js里的React
Native应用 5. 构建Android应用 Android
测试 • Jest Tests(JS-only) • 单元测试(buckbuild) • 集成测试(buckbuild with Android
SDK+NDK) • iOS有Snapshot Tests ဳғJestฎचԭJasmine҅य़᮱ړAPIฎ᭗አጱ
发布 • CodePush类服务(操作简单,但是需要APP继承SDK) • 自己搭建部署服务(iCode+Agile+ORP)
Content • React Native ᓌՕ • ᭌೠReact NativeҘ • ই֜ଫአReact
NativeҘ • Demoᄍᐏ • ᷚᴾ݊
Demo演示 iOS
Demo演示 Android
Demo演示 Web
Demo资料 • msbu-react group • 上线bundle • babel静态资源处理插件
一些坑 • Android中Android SDK Build-Tools V23.0.1限制 • 三端同构产出内容需要微调抹平(如flex布局元素height) • 产出bundle内容处理(自写babel插件替换资源路径)
• 等等,其实还有很多,宝宝突然懵圈想不起来了
Content • React Native ᓌՕ • ᭌೠReact NativeҘ • ই֜ଫአReact
NativeҘ • Demoᄍᐏ • ᷚᴾ݊
风险及挑战 • 面临的问题及处理办法 • 构建React Native生态
面临的问题 • 版本支持度:Android 4.1+、iOS 7.0+ • 性能在高低端机型上呈两极 • 部分非常用组件存在平台差异 •
项目不成熟,版本不稳定,官方文档较少 • 对开发者的综合能力要求较高 • Web端SEO劣势
处理办法 • 版本支持度:目前App的兼容范围Cover,低版本降级处理 • 低端机性能:低端机型提供核心功能降级Web版本 • 平台性差异:搭建组件库,抹平差异 • 项目不成熟:自建生态,保持对社区的敏锐嗅觉 •
开发者能力:提供整套开发解决方案,降低研发成本 • Web端SEO:服务器端渲染
构建React Native生态 რ ݎ ᧣ᦶ ၥᦶ ݎ ࢧ჻ ፊഴ ս۸
ݎ֛ḵ̵ᗑᕶ๐ۓ ᚆ̵አಁ֛ḵ ᚆ̵Კ̵አಁᤈԅ ىഴګ̵ᴳᕆکweb ᛔᖫᦲ۱̵૧ړୌ̵ےੂ॒ቘ ORPӤᕚ̵WebᒒݶӤᕚ ଉᥢ፥ၥᦶ MVPग़ᦡ॓ԯᒒၥᦶ Chrome Developer Tools ෭பګ̵ሾहڔഘګ ݎሾह൫ୌ̵ݎᘏଘݣҁDEMO//ᩒᦔ҂ ጯଶ܅ኞAppᵞ౮̵चᏐᕟկ݊ӱۓᕟկ ᐒ܄ᨯሠ̵݇Өრ
React Native资料 • facebook-react-native • awesome-react-native • react & redux
Q&A