SlideShare a Scribd company logo
Rails +React + React Native
A common codebase across web and mobile
@TalkingQuickly
Rails = Productivity
@TalkingQuickly
Mobile = Not Productivity
@TalkingQuickly
React (+Native) = Productivity
@TalkingQuickly
I’m Ben
@TalkingQuickly
Aim of this talk
• General Architecture
• Considerations for a shared codebase
• Practicalities & Pitfalls
@TalkingQuickly
React != Framework
@TalkingQuickly
But this is“Built In React” !?
@TalkingQuickly
Typical React Stack
State
React
Side Effects
Router
@TalkingQuickly
Typical React Stack
State
Side Effects
Router
React
@TalkingQuickly
Typical React Stack
Router
State
Side Effects
React
@TalkingQuickly
State
Typical React Stack
Router
React
Side Effects
@TalkingQuickly
Oversimplifying Flux / Redux
function counterReducer(initialState = {}, action) {
switch (action.type) {
case 'INCREMENT':
return Object.assign({}, initialState, {
count: initialState.count + action.incrementBy
})
case 'DECREMENT':
return Object.assign({}, state, {
count: initialState.count - action.decrementBy
})
default:
return initialState
}
}
{
count: 1,
name: ‘Jim’,
rank: 4
}
initialState
{
type: 'INCREMENT',
incrementBy: 1
}
action
{
count: 2,
name: ‘Jim’,
rank: 4
}
New State
@TalkingQuickly
Side Effects
Typical React Stack
Router
React
State
@TalkingQuickly
Side Effects Asynchronous Stuff
{
type: 'INCREMENT',
incrementBy: 5
}
action
{
count: 6,
name: ‘Jim’,
rank: 4
}
New State
API Call
“Side Effect” (Saga)
@TalkingQuickly
Router
State
React
Side Effects
What should be shared
@TalkingQuickly
What should be shared
Router
State
Side Effects
React
@TalkingQuickly
In Practice: Login Flow
Show the login screen
(Component)
Click Login (dispatch an
action)
Go To Login (Router)
Update flag that we’re
logging in (Store)
Make login API request
(Side effect)
@TalkingQuickly
In Practice: Login Flow
Handle successful
response (dispatch an
action)
Update flag that we’re now
logged in (Store)
Send user to dashboard
(side effect)
Make login API request
(Side effect)
@TalkingQuickly
In Practice: Login Flow
Issue Redirect
Send user to dashboard
(side effect)
Router
@TalkingQuickly
In Practice: Login Flow
Issue Redirect
Send user to dashboard
(side effect)
Router
Send user to dashboard
(side effect)
Router
Invoke Callback
Redirect (Component)
@TalkingQuickly
Business Logic is Shared
Show the login screen
(Component)
Click Login (dispatch an
action)
Go To Login (Router)
Update flag that we’re
logging in (Store)
Make login API request
(Side effect)
@TalkingQuickly
Business Logic is Shared
Components
Actions
Router
Reducers
Side Effects
Side Effects
@TalkingQuickly
Start with Native
• Ignite Generator (!)
• https://github.com/infinitered/ignite
@TalkingQuickly
Restructure
• App/
• Shared/
• Sagas
• Redux
• …etc
• Native/
• Web/
@TalkingQuickly
Restructure
• App/
• Shared/
• Sagas
• Redux
• …etc
• Native/
• Web/
NPM Package
@TalkingQuickly
Watch out for .babelrc
—resetCache
@TalkingQuickly
Example Project
www.talkingquickly.co.uk/railsconf2017
ben@joincatapult.com

More Related Content

What's hot (20)

PPTX
Rethinking Best Practices
floydophone
 
PPTX
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
PDF
Designing applications with Redux
Fernando Daciuk
 
PDF
React and redux
Mystic Coders, LLC
 
PDF
Building Modern Web Applications using React and Redux
Maxime Najim
 
PDF
How to Redux
Ted Pennings
 
PDF
React.js and Redux overview
Alex Bachuk
 
PDF
Workshop React.js
Commit University
 
PDF
React + Redux for Web Developers
Jamal Sinclair O'Garro
 
PDF
Introduce Flux & react in practices (KKBOX)
Hsuan Fu Lien
 
PDF
Intro to ReactJS
Harvard Web Working Group
 
PDF
React for Dummies
Mitch Chen
 
PDF
React Native +Redux + ES6 (Updated)
Chiew Carol
 
PDF
Workshop 22: React-Redux Middleware
Visual Engineering
 
PPTX
Better web apps with React and Redux
Ali Sa'o
 
PPTX
React / Redux Architectures
Vinícius Ribeiro
 
PPTX
A Brief Introduction to React.js
Doug Neiner
 
PPT
React js
Jai Santhosh
 
PDF
Angular redux
Nir Kaufman
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
Rethinking Best Practices
floydophone
 
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
Designing applications with Redux
Fernando Daciuk
 
React and redux
Mystic Coders, LLC
 
Building Modern Web Applications using React and Redux
Maxime Najim
 
How to Redux
Ted Pennings
 
React.js and Redux overview
Alex Bachuk
 
Workshop React.js
Commit University
 
React + Redux for Web Developers
Jamal Sinclair O'Garro
 
Introduce Flux & react in practices (KKBOX)
Hsuan Fu Lien
 
Intro to ReactJS
Harvard Web Working Group
 
React for Dummies
Mitch Chen
 
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Workshop 22: React-Redux Middleware
Visual Engineering
 
Better web apps with React and Redux
Ali Sa'o
 
React / Redux Architectures
Vinícius Ribeiro
 
A Brief Introduction to React.js
Doug Neiner
 
React js
Jai Santhosh
 
Angular redux
Nir Kaufman
 
[Final] ReactJS presentation
洪 鹏发
 

Similar to Railsconf 2017 - React & React Native a common codebase across native and web (20)

PDF
React native
Vishal Dubey
 
PDF
React Native for multi-platform mobile applications
Matteo Manchi
 
PDF
Pieter De Baets - An introduction to React Native
tlv-ios-dev
 
PDF
Robust web apps with React.js
Max Klymyshyn
 
PPTX
React.js at Cortex
Geoff Harcourt
 
PDF
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
PDF
An Intense Overview of the React Ecosystem
Rami Sayar
 
PPTX
React gsg presentation with ryan jung & elias malik
Lama K Banna
 
PDF
React native: building native iOS apps with javascript
Polidea
 
PPTX
Creating books app with react native
Ali Sa'o
 
PDF
The Gist of React Native
Darren Cruse
 
PDF
React Native App Development: A Comprehensive Guide
Lucy Zeniffer
 
PPTX
Introduction to react native with redux
Mike Melusky
 
PDF
React js vs react native a comparative analysis
Shelly Megan
 
PPTX
React. Flux. Redux. by Andrey Kolodnitskiy
Valeriia Maliarenko
 
PDF
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
GreeceJS
 
PDF
From Back to Front: Rails To React Family
Khor SoonHin
 
PDF
What Is React Native? Guide to Mobile App Development
GrapesTech Solutions
 
PDF
Advantages of building Social Media Apps in React Native
Shelly Megan
 
PDF
Reasons to Choose React Native for building Social Media/Networking Apps!
Shelly Megan
 
React native
Vishal Dubey
 
React Native for multi-platform mobile applications
Matteo Manchi
 
Pieter De Baets - An introduction to React Native
tlv-ios-dev
 
Robust web apps with React.js
Max Klymyshyn
 
React.js at Cortex
Geoff Harcourt
 
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
An Intense Overview of the React Ecosystem
Rami Sayar
 
React gsg presentation with ryan jung & elias malik
Lama K Banna
 
React native: building native iOS apps with javascript
Polidea
 
Creating books app with react native
Ali Sa'o
 
The Gist of React Native
Darren Cruse
 
React Native App Development: A Comprehensive Guide
Lucy Zeniffer
 
Introduction to react native with redux
Mike Melusky
 
React js vs react native a comparative analysis
Shelly Megan
 
React. Flux. Redux. by Andrey Kolodnitskiy
Valeriia Maliarenko
 
React Native and the future of web technology (Mark Wilcox) - GreeceJS #15
GreeceJS
 
From Back to Front: Rails To React Family
Khor SoonHin
 
What Is React Native? Guide to Mobile App Development
GrapesTech Solutions
 
Advantages of building Social Media Apps in React Native
Shelly Megan
 
Reasons to Choose React Native for building Social Media/Networking Apps!
Shelly Megan
 
Ad

Recently uploaded (20)

PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Ad

Railsconf 2017 - React & React Native a common codebase across native and web