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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
David Zhang
September 02, 2016
Programming
390
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ReactNative 探索之路
来自 Dengxi (@regrex)
David Zhang
September 02, 2016
More Decks by David Zhang
See All by David Zhang
ngx_share: conf & module
crispgm
0
29
Nginx 事件驱动机制
crispgm
0
560
Other Decks in Programming
See All in Programming
JavaDoc 再入門
nagise
1
430
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
1
530
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
120
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
870
Oxlintのカスタムルールの現況
syumai
6
1.2k
act1-costs.pdf
sumedhbala
0
120
The NotImplementedError Problem in Ruby
koic
1
970
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
150
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
810
どこまでゆるくて許されるのか
tk3fftk
0
260
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
8.6k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
220
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
What's in a price? How to price your products and services
michaelherold
247
13k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
570
Mind Mapping
helmedeiros
PRO
1
270
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Speed Design
sergeychernyshev
33
1.9k
sira's awesome portfolio website redesign presentation
elsirapls
0
290
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Crafting Experiences
bethany
1
190
Designing for humans not robots
tammielis
254
26k
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