$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ReactNative 探索之路
Search
David Zhang
September 02, 2016
Programming
1
370
ReactNative 探索之路
来自 Dengxi (@regrex)
David Zhang
September 02, 2016
Tweet
Share
More Decks by David Zhang
See All by David Zhang
ngx_share: conf & module
crispgm
0
26
Nginx 事件驱动机制
crispgm
0
540
Other Decks in Programming
See All in Programming
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
370
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
400
Microservices rules: What good looks like
cer
PRO
0
1.6k
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
430
マスタデータ問題、マイクロサービスでどう解くか
kts
0
110
Tinkerbellから学ぶ、Podで DHCPをリッスンする手法
tomokon
0
140
俺流レスポンシブコーディング 2025
tak_dcxi
14
9.1k
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
140
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.5k
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
860
AIコーディングエージェント(skywork)
kondai24
0
190
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
2
220
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
160
Rails Girls Zürich Keynote
gr2m
95
14k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Technical Leadership for Architectural Decision Making
baasie
0
180
The agentic SEO stack - context over prompts
schlessera
0
550
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
310
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
0
270
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
2
2.7k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
54k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
99
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