SlideShare a Scribd company logo
Philip Shurpik "Architecting React Native app"
About me
Creating magic with React Native
in Debitoor/Ciklum :)
What are we doing?
Goals before development started
+ Fast to develop with existing JavaScript team
+ Firstly for iOS, then for Android
+ Offline first
+ Mostly native look and feel - animations, visual
effects, etc...
Sharing code between
platforms
It’s possible to share 70-80-90% of code between platforms
Depending on:
+ Architecture
+ Functionality
+ Third-party plugins usage
Sharing code between platforms
Can be shared
+ Business logic
+ Container components
Sharing code between platforms
Can’t be shared
- Platform specific stuff
- Different interface
patterns
Can be shared
+ Business logic
+ Container components
Sharing code between platforms
Can’t be shared
- Platform specific stuff
- Different interface
patterns
It depends...
● Code that works with plugins
● Presentational Components
(depending on design)
Let’s make app architecture
* That’s how React/React Native ecosystem looks like :)
Let’s start from basement
View and Business Logic separation with Redux
tap tap...
User
Container
Component
Thanks @andrestaltz for inspiration
State
Reducer
Middleware
Store
Presentational
Components
View
Actions
Reducer
API
Render data
But…
Sometimes...
Philip Shurpik "Architecting React Native app"
But not all apps are working offline...
And even don’t forget your maps route screenshot
...we are offline
tap tap...
User
Container
Component
State
Reducer
Middleware
Store
Presentational
Components
View
Actions
Reducer
API
Render
?
?
We can solve a lot of problems it in few lines of code
+ Persist store state on each change to AsyncStorage
+ Rehydrate store on App Start
const store = createStore(reducer, compose(
applyMiddleware(/* ... some middleware */),
autoRehydrate()
));
Using redux-persist enhancer
persistStore(store, {storage: AsyncStorage});
Redux-persist
Persist store state on each change to AsyncStorage
Container
Component
State
Reducer
Middleware
Store
Presentational
Components
View
Reducer
Device
AsyncStorage
Render
Actions
Redux-persist
Auto rehydrate store on Application start
Container
Component
State
Reducer
Middleware
Store
Presentational
Components
View
Reducer
Device
AsyncStorage
Initial
Render
Actually we received
offline-first for viewing data
Let’s improve :)
Viewing data offline
tap tap...
User
Container
Component
Store
Presentational
Components
View
Actions
API
Render
existing data
Adding
“offline”
label
Redux-persist
State
Reducer
Middleware
Reducer
Marking
data as
outdated
Optimistically
render
new data
Creating data offline (optimistic ui)
tap tap...
User
Container
Component
Store
Presentational
Components
View
Actions
API
Adding
“not sync”
label
Redux-persist
State
Reducer
Middleware
Reducer
Marking data
as not
synchronised
Hints
Generate item Ids on client
Hints
If you have some data dependencies
invoice depending on client and product
make simple dependency tree for
synchronisation order
Hints
Use storage version to not break anything
while updating app
Hints
Offline-first editing of existing data is much more
complicated:
+ Deal with conflicts
+ Sync challenges
+ Multiple users challenges
* Do it only if it’s one of the main selling points of your app
Navigation
Navigator
NavigatorIOS
NavigationExperimental
react-native-router-flux
react-native-navigation
ex-navigation
ex-navigator
react-native-router
react-router-native
react-native-simple-router
react-native-controllers
Navigation approaches
JS-based Navigation
● Navigator
● NavigationExperimental
● react-native-router-flux
● ex-navigation
● ...
Native Navigation
● NavigatorIOS
● react-native-navigation
(wix)
● airbnb solution (not yet
opensourced)
Pros:
+ Works with all latest RN versions
+ Declarative approach:
<Router createReducer={reducerCreate}>
<Scene key="loginPage" component={LoginPage} title="Login"/>
...
</Router>
+ Can be easily debugged (it’s just JS code)
+ Has good custom extensions support
React-native-router-flux
Cons:
- Bad documentation
- Non native JS animations, non native styles
- Unable to smoothly integrate with existing IOS/Android apps
React-native-router-flux
Pros:
+ Native user experience for Android and IOS platforms
+ Developed and supported by Wix
Cons:
- You need to know Objective C/Java to debug it/fix issue
- Hard to implement something really custom
- Limited React Native version support
(stable version supports 0.25.1 and experimental 0.37.0)
React-native-navigation
Performance hints
React Native Threads Communication
JS Thread
(JavaScriptCore)
Native Thread UI (Main) Thread
Async
Bridge
Process Serialize Deserialize
Process
Render
Long
process
Becomes
not
responsive
Process
How to improve
+ Use shouldComponentUpdate - avoid not needed rendering
(and bridging from JS to UI thread)
+ Run calculations after animations finish with
InteractionManager.runAfterInteractions
+ Offload animations to UI Thread with Layout Animation
+ If everything is completely wrong - write Native code (we
haven’t experienced such situations)
Going to production - expected path
Write some JS code
Going to production - actually
Write some JS code
Tests and CI setup example at: https://git.io/rnstk
What we need besides JS code
● Javascript tests: Unit and components
Unit tests - example
describe('auth.reducer', () => {
it('should set token on login success', () => {
const action = {
type: types.AUTH_LOGIN_SUCCESS,
payload: {token: '111'}
};
expect(auth(INITIAL_STATE, action)).to.be.deep.equal({
...INITIAL_STATE,
token: '111',
loading: false
});
});
});
Components testing
+ enzyme
+ react-native-mock
+ chai-enzyme
Components tests with Enzyme - example
describe('Button.spec.js', () => {
let wrapper, pressHandler;
beforeEach(() => {
pressHandler = sinon.stub();
wrapper = shallow(<Button onPress={pressHandler}>text</Button>);
});
it('should render text in button', () => {
const text = wrapper.find(Text).first();
expect(text).to.have.prop('children', 'text');
});
it('should handle press', () => {
wrapper.simulate('Press');
expect(pressHandler).to.have.been.calledOnce;
});
});
Integrational (end to end) tests
● Javascript tests: Unit and components
● Integrational (end to end) tests:
○ Write in JavaScript - yeah, we are JS developers! :)
○ Run app on simulator
○ Login (check API work)
○ Went through main functionality and check that it works
Appium - architecture
● Uses Selenium Webdriver
● Appium is an HTTP server that creates and handles WebDriver sessions
● Appium starts “test case” on device that spawns a server and listen for
proxied commands
Appium test
The same tests crossplatform
The same tests crossplatform
React Native uses different props
to access elements on iOS and
Android.
Hope will be fixed soon:
https://github.com/facebook/react-
native/pull/9942
Test Example
it('should login', () => getDriver()
.waitAndClickElement('SignIn')
.waitForElement('Login')
.setElementValue('Email', EMAIL)
.setElementValue('Password', PASSWORD)
.clickElement('Login')
.waitForElement('Dashboard')
)
* With using of custom methods created with wd.addPromiseChainMethod
What about automating custom actions?
Like:
+ Signin
+ Signout
+ Redirect to page
example at: https://git.io/rnstk
Automate commands
Appium
test
Mobile
TestRunner
Action Server
(serves actions)
Push action
Press execute
button
fetch action
get action
dispatch action
example at: https://git.io/rnstk
Continuous delivery
Continuous delivery with Fastlane
+ Manage certificates and provision profiles (for iOS)
+ Make app builds (for iOS)
+ Submits Beta builds to TestFlight / PlayStore alpha track
+ Submits Release builds to AppStore / PlayStore
but...
- We need to wait before Apple approves our app
- Users do not update their apps for a long time
- If you update app through appstore it resets user reviews :(
- It’s harder to support different versions of app - especially for
supporters :)
We need to be able to update javascript immediately (like on web)
CodePush
Cloud service with React Native support
CodePush
Deploy Code updates directly to
users:
code-push release-react MyApp ios
● JS Bundle
● Image assets
CodePush features
● Separate Staging and Production versions
● Promoting updates
○ Partially promoting (like 20%)
○ A/B testing
● Rollback updates
○ Auto-rollback if app crashes
Links
React Native Starter Kit:
https://github.com/philipshurpik/react-native-starter-kit
Performance tuning:
https://medium.com/@talkol/performance-limitations-of-react-native-an
d-how-to-overcome-them-947630d7f440#.2dsdud7yr
https://facebook.github.io/react-native/docs/android-ui-performance.ht
ml
Questions
skype: philipshurpik
twitter: philipshurpik
https://github.com/philipshurpik

More Related Content

PDF
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
PDF
The Road to Native Web Components
PDF
A tour of React Native
PDF
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
PDF
The Gist of React Native
PDF
Node.js and Selenium Webdriver, a journey from the Java side
PPT
PDF
Using JHipster for generating Angular/Spring Boot apps
Григорий Шехет "Treasure hunt in the land of Reactive frameworks"
The Road to Native Web Components
A tour of React Native
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
The Gist of React Native
Node.js and Selenium Webdriver, a journey from the Java side
Using JHipster for generating Angular/Spring Boot apps

What's hot (20)

PDF
Introducing Playwright's New Test Runner
PPTX
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
PPTX
Angular 2 Migration - JHipster Meetup 6
PDF
Testing nightwatch, by David Torroija
PDF
Fullstack End-to-end test automation with Node.js, one year later
PDF
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
PDF
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
PPTX
React Native for ReactJS Devs
PDF
Testing Web Applications
PDF
Night Watch with QA
PDF
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
PDF
Intro to JavaScript
PDF
React Native custom components
PPTX
Test-Driven JavaScript Development (JavaZone 2010)
PDF
A Closer Look At React Native
PDF
The Many Ways to Test Your React App
PDF
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
PDF
JavaScript, React Native and Performance at react-europe 2016
PPTX
Nightwatch JS for End to End Tests
PDF
JavaFX JumpStart @JavaOne 2016
Introducing Playwright's New Test Runner
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Angular 2 Migration - JHipster Meetup 6
Testing nightwatch, by David Torroija
Fullstack End-to-end test automation with Node.js, one year later
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Native for ReactJS Devs
Testing Web Applications
Night Watch with QA
GlobalLogic Test Automation Online TechTalk “Playwright — A New Hope”
Intro to JavaScript
React Native custom components
Test-Driven JavaScript Development (JavaZone 2010)
A Closer Look At React Native
The Many Ways to Test Your React App
Matteo Manchi - React Native for multi-platform mobile applications - Codemot...
JavaScript, React Native and Performance at react-europe 2016
Nightwatch JS for End to End Tests
JavaFX JumpStart @JavaOne 2016
Ad

Viewers also liked (20)

PPTX
Илья Климов "О драконах ни слова"
PDF
Intro to react native
PDF
React Native Android. It's easy.
PDF
Евгений Жарков "Как быть хорошим фронтенд-разработчиком"
PDF
Алексей Волков "Еще несколько слов об архитектуре"
PDF
Алексей Косинский "React Native vs. React+WebView"
PPTX
Денис Яремов "Offline-first приложение на Reflex"
PPTX
Сергей Морковкин "Разработка realtime SPA с использованием VueJS и RethinkDB"
PDF
Юлия Пучнина "PhaserJS for advertisement: игры внутри баннеров"
PPTX
React Native + Redux, a game changer for mobile application development?
PDF
Styling React Native Applications
PPT
Владимир Никонов "Вызовы при разработке enterprise продукта"
PPTX
Meetup React Native
PDF
Putting the Native in React Native - React Native Boston
PPTX
SONY BBS - React Native
PDF
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
PDF
Microservices with Apache Camel, DDD, and Kubernetes
PDF
React + Redux for Web Developers
PDF
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
PDF
Андрей Шумада | Tank.ly
Илья Климов "О драконах ни слова"
Intro to react native
React Native Android. It's easy.
Евгений Жарков "Как быть хорошим фронтенд-разработчиком"
Алексей Волков "Еще несколько слов об архитектуре"
Алексей Косинский "React Native vs. React+WebView"
Денис Яремов "Offline-first приложение на Reflex"
Сергей Морковкин "Разработка realtime SPA с использованием VueJS и RethinkDB"
Юлия Пучнина "PhaserJS for advertisement: игры внутри баннеров"
React Native + Redux, a game changer for mobile application development?
Styling React Native Applications
Владимир Никонов "Вызовы при разработке enterprise продукта"
Meetup React Native
Putting the Native in React Native - React Native Boston
SONY BBS - React Native
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
Microservices with Apache Camel, DDD, and Kubernetes
React + Redux for Web Developers
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
Андрей Шумада | Tank.ly
Ad

Similar to Philip Shurpik "Architecting React Native app" (20)

PPTX
From React to React Native - Things I wish I knew when I started
PPTX
20180518 QNAP Seminar - Introduction to React Native
PDF
(Js) Export your own WebGL Viewer
PDF
React Native - DILo Surabaya
PDF
Crash Course in AngularJS + Ionic (Deep dive)
PDF
Node azure
PPTX
Nodejs web service for starters
PPTX
Mobile UI Testing using Appium and Docker
PPTX
Django simplified : by weever mbakaya
PDF
Full Stack React Workshop [CSSC x GDSC]
PDF
Griffon for the Enterprise
PPTX
Web Development and Web Development technologies - Temitayo Fadojutimi
PPTX
Expo - Zero to App.pptx
PPTX
Mobile Application and Developments.pptx
PDF
Progressive Web Application by Citytech
PPTX
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
PDF
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
PPTX
React Native: Introduction
PPTX
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
PPTX
Introduction to react native @ TIC NUST
From React to React Native - Things I wish I knew when I started
20180518 QNAP Seminar - Introduction to React Native
(Js) Export your own WebGL Viewer
React Native - DILo Surabaya
Crash Course in AngularJS + Ionic (Deep dive)
Node azure
Nodejs web service for starters
Mobile UI Testing using Appium and Docker
Django simplified : by weever mbakaya
Full Stack React Workshop [CSSC x GDSC]
Griffon for the Enterprise
Web Development and Web Development technologies - Temitayo Fadojutimi
Expo - Zero to App.pptx
Mobile Application and Developments.pptx
Progressive Web Application by Citytech
European Collaboration Summit - SharePoint Framework Angular & Azure Functions
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
React Native: Introduction
Vue Storefront - Progressive Web App for Magento (1.9, 2.x) - MM18DE speech
Introduction to react native @ TIC NUST

More from Fwdays (20)

PDF
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
PPTX
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
PPTX
"Як ми переписали Сільпо на Angular", Євген Русаков
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
PDF
"Validation and Observability of AI Agents", Oleksandr Denisyuk
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
PPTX
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
PPTX
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
PDF
"AI is already here. What will happen to your team (and your role) tomorrow?"...
PPTX
"Is it worth investing in AI in 2025?", Alexander Sharko
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
PDF
"Scaling in space and time with Temporal", Andriy Lupa .pdf
PPTX
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
PPTX
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
PPTX
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
"Як ми переписали Сільпо на Angular", Євген Русаков
"AI Transformation: Directions and Challenges", Pavlo Shaternik
"Validation and Observability of AI Agents", Oleksandr Denisyuk
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
"AI is already here. What will happen to your team (and your role) tomorrow?"...
"Is it worth investing in AI in 2025?", Alexander Sharko
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Database isolation: how we deal with hundreds of direct connections to the d...
"Scaling in space and time with Temporal", Andriy Lupa .pdf
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Empathic Computing: Creating Shared Understanding
PDF
Approach and Philosophy of On baking technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Getting Started with Data Integration: FME Form 101
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Reach Out and Touch Someone: Haptics and Empathic Computing
Empathic Computing: Creating Shared Understanding
Approach and Philosophy of On baking technology
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
cloud_computing_Infrastucture_as_cloud_p
A comparative analysis of optical character recognition models for extracting...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Network Security Unit 5.pdf for BCA BBA.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Philip Shurpik "Architecting React Native app"

  • 2. About me Creating magic with React Native in Debitoor/Ciklum :)
  • 3. What are we doing?
  • 4. Goals before development started + Fast to develop with existing JavaScript team + Firstly for iOS, then for Android + Offline first + Mostly native look and feel - animations, visual effects, etc...
  • 6. It’s possible to share 70-80-90% of code between platforms Depending on: + Architecture + Functionality + Third-party plugins usage Sharing code between platforms
  • 7. Can be shared + Business logic + Container components Sharing code between platforms Can’t be shared - Platform specific stuff - Different interface patterns
  • 8. Can be shared + Business logic + Container components Sharing code between platforms Can’t be shared - Platform specific stuff - Different interface patterns It depends... ● Code that works with plugins ● Presentational Components (depending on design)
  • 9. Let’s make app architecture
  • 10. * That’s how React/React Native ecosystem looks like :)
  • 11. Let’s start from basement
  • 12. View and Business Logic separation with Redux tap tap... User Container Component Thanks @andrestaltz for inspiration State Reducer Middleware Store Presentational Components View Actions Reducer API Render data
  • 15. But not all apps are working offline...
  • 16. And even don’t forget your maps route screenshot
  • 17. ...we are offline tap tap... User Container Component State Reducer Middleware Store Presentational Components View Actions Reducer API Render ? ?
  • 18. We can solve a lot of problems it in few lines of code + Persist store state on each change to AsyncStorage + Rehydrate store on App Start const store = createStore(reducer, compose( applyMiddleware(/* ... some middleware */), autoRehydrate() )); Using redux-persist enhancer persistStore(store, {storage: AsyncStorage});
  • 19. Redux-persist Persist store state on each change to AsyncStorage Container Component State Reducer Middleware Store Presentational Components View Reducer Device AsyncStorage Render Actions
  • 20. Redux-persist Auto rehydrate store on Application start Container Component State Reducer Middleware Store Presentational Components View Reducer Device AsyncStorage Initial Render
  • 21. Actually we received offline-first for viewing data Let’s improve :)
  • 22. Viewing data offline tap tap... User Container Component Store Presentational Components View Actions API Render existing data Adding “offline” label Redux-persist State Reducer Middleware Reducer Marking data as outdated
  • 23. Optimistically render new data Creating data offline (optimistic ui) tap tap... User Container Component Store Presentational Components View Actions API Adding “not sync” label Redux-persist State Reducer Middleware Reducer Marking data as not synchronised
  • 25. Hints If you have some data dependencies invoice depending on client and product make simple dependency tree for synchronisation order
  • 26. Hints Use storage version to not break anything while updating app
  • 27. Hints Offline-first editing of existing data is much more complicated: + Deal with conflicts + Sync challenges + Multiple users challenges * Do it only if it’s one of the main selling points of your app
  • 30. Navigation approaches JS-based Navigation ● Navigator ● NavigationExperimental ● react-native-router-flux ● ex-navigation ● ... Native Navigation ● NavigatorIOS ● react-native-navigation (wix) ● airbnb solution (not yet opensourced)
  • 31. Pros: + Works with all latest RN versions + Declarative approach: <Router createReducer={reducerCreate}> <Scene key="loginPage" component={LoginPage} title="Login"/> ... </Router> + Can be easily debugged (it’s just JS code) + Has good custom extensions support React-native-router-flux
  • 32. Cons: - Bad documentation - Non native JS animations, non native styles - Unable to smoothly integrate with existing IOS/Android apps React-native-router-flux
  • 33. Pros: + Native user experience for Android and IOS platforms + Developed and supported by Wix Cons: - You need to know Objective C/Java to debug it/fix issue - Hard to implement something really custom - Limited React Native version support (stable version supports 0.25.1 and experimental 0.37.0) React-native-navigation
  • 35. React Native Threads Communication JS Thread (JavaScriptCore) Native Thread UI (Main) Thread Async Bridge Process Serialize Deserialize Process Render Long process Becomes not responsive Process
  • 36. How to improve + Use shouldComponentUpdate - avoid not needed rendering (and bridging from JS to UI thread) + Run calculations after animations finish with InteractionManager.runAfterInteractions + Offload animations to UI Thread with Layout Animation + If everything is completely wrong - write Native code (we haven’t experienced such situations)
  • 37. Going to production - expected path Write some JS code
  • 38. Going to production - actually Write some JS code Tests and CI setup example at: https://git.io/rnstk
  • 39. What we need besides JS code ● Javascript tests: Unit and components
  • 40. Unit tests - example describe('auth.reducer', () => { it('should set token on login success', () => { const action = { type: types.AUTH_LOGIN_SUCCESS, payload: {token: '111'} }; expect(auth(INITIAL_STATE, action)).to.be.deep.equal({ ...INITIAL_STATE, token: '111', loading: false }); }); });
  • 41. Components testing + enzyme + react-native-mock + chai-enzyme
  • 42. Components tests with Enzyme - example describe('Button.spec.js', () => { let wrapper, pressHandler; beforeEach(() => { pressHandler = sinon.stub(); wrapper = shallow(<Button onPress={pressHandler}>text</Button>); }); it('should render text in button', () => { const text = wrapper.find(Text).first(); expect(text).to.have.prop('children', 'text'); }); it('should handle press', () => { wrapper.simulate('Press'); expect(pressHandler).to.have.been.calledOnce; }); });
  • 43. Integrational (end to end) tests ● Javascript tests: Unit and components ● Integrational (end to end) tests: ○ Write in JavaScript - yeah, we are JS developers! :) ○ Run app on simulator ○ Login (check API work) ○ Went through main functionality and check that it works
  • 44. Appium - architecture ● Uses Selenium Webdriver ● Appium is an HTTP server that creates and handles WebDriver sessions ● Appium starts “test case” on device that spawns a server and listen for proxied commands Appium test
  • 45. The same tests crossplatform
  • 46. The same tests crossplatform React Native uses different props to access elements on iOS and Android. Hope will be fixed soon: https://github.com/facebook/react- native/pull/9942
  • 47. Test Example it('should login', () => getDriver() .waitAndClickElement('SignIn') .waitForElement('Login') .setElementValue('Email', EMAIL) .setElementValue('Password', PASSWORD) .clickElement('Login') .waitForElement('Dashboard') ) * With using of custom methods created with wd.addPromiseChainMethod
  • 48. What about automating custom actions? Like: + Signin + Signout + Redirect to page example at: https://git.io/rnstk
  • 49. Automate commands Appium test Mobile TestRunner Action Server (serves actions) Push action Press execute button fetch action get action dispatch action example at: https://git.io/rnstk
  • 51. Continuous delivery with Fastlane + Manage certificates and provision profiles (for iOS) + Make app builds (for iOS) + Submits Beta builds to TestFlight / PlayStore alpha track + Submits Release builds to AppStore / PlayStore
  • 52. but... - We need to wait before Apple approves our app - Users do not update their apps for a long time - If you update app through appstore it resets user reviews :( - It’s harder to support different versions of app - especially for supporters :) We need to be able to update javascript immediately (like on web)
  • 53. CodePush Cloud service with React Native support
  • 54. CodePush Deploy Code updates directly to users: code-push release-react MyApp ios ● JS Bundle ● Image assets
  • 55. CodePush features ● Separate Staging and Production versions ● Promoting updates ○ Partially promoting (like 20%) ○ A/B testing ● Rollback updates ○ Auto-rollback if app crashes
  • 56. Links React Native Starter Kit: https://github.com/philipshurpik/react-native-starter-kit Performance tuning: https://medium.com/@talkol/performance-limitations-of-react-native-an d-how-to-overcome-them-947630d7f440#.2dsdud7yr https://facebook.github.io/react-native/docs/android-ui-performance.ht ml