SlideShare a Scribd company logo
1
Use React Patterns To Build
Large Scalable App
Jay Chung @ Modern Web 2018, TW
2
Components
3
SliderNavs
Button
Modal
Loader
Toast
Anchor Table
Radio
NavBar
Dropdown
App
App
4
Patterns
5
6
Small Clues Tell
7
3
4
10
3
8
3
4
10
3
32
+ 42
= 5 102
= 100 32
π
Fix Problems with Elegance
different clues with different patterns
9
Children as Functions
https://github.com/drcmda/react-spring
10
Higher Order Render Props
https://github.com/drcmda/react-spring
11
Higher Order Component
https://github.com/erikras/redux-form
12
Provider Pattern
https://github.com/yahoo/react-intl
13
Compound Component
https://github.com/ant-design/ant-design/
14
STEP 1
container component
A Pattern Journey
STEP 2
compound component
STEP 3
render props
STEP 4
higher order component
STEP 5
provider pattern
Jay Chung (xJkit)
https://github.com/xJkit
https://linkedin.com/in/xjkit54780
https://slideshare.net/JOEYCHUNG2
https://twitter.com/xJkit
About Me
Front End Developer
https://github.com/xJkit/modern-web-2018-demo
https://github.com/xJkit/modern-web-2018-demo
17
Inline Editing Component
18
https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0
20
How Things Work
Container Component
data fetching/state changes
How Things Look
Presentational Component
markup, style
Use React Patterns to Build Large Scalable App
22
Presentational Component
23
Container Component
24
Container Component
25
26
InlineEditing in Table renderer
27
InlineEditing Component
Use React Patterns to Build Large Scalable App
29
How to custom button or input styles?
How to change button order or position?
30
How to custom UI styles?
31
You need more props!
🤮
32
STEP 02
A Pattern Journey
33
Container Component
34
Presentational Components Exposed
Use React Patterns to Build Large Scalable App
36
Presentational Components Exposed
React Top Level API
38
Children eat different props
39
Children connect at root
40
Fix Grandchildren Components
41
Context Provider
42
Context Consumer
43
How to use my own UI components?
44
Step 3
A Pattern Journey
45
46
Render channel
Renderless container
Use React Patterns to Build Large Scalable App
48
A render prop is a function prop that
a component uses to know what to render.
49
50
Compound Component
51
Get Everything From
A Render Prop
52
Pass Everything Into
A Render Prop
53
54
Put Your Custom
Components Here
55
Parent decides
how to render
Props collection
56
children
Render Props
Rename
57
children Render Props
Rename
58
Child as a functional component
59
More Use Cases
https://github.com/chenglou/react-motion
61
React Motion
Get styles and you decide
how to render
https://github.com/renatorib/react-powerplug
63
Renderless Containers
64
Only part of components
need state
https://github.com/xJkit/react-goodbye
66
Save reminder modal
How to use HoC for authorization?
68
No logic in App
Logic in the HoC
69
No logic in App
Logic in the HoCs
70
No logic in App
Logic in these HoCs
71
Get More as You Compose
be careful of “name collision”
Utility Components by HoCs
Use React Patterns to Build Large Scalable App
Render Props & HoC
are interchangeable
75
Render Props & HoC are interchangeable
HoC version
76
Render Props & HoC are interchangeable
Render Props version
77
withNetwork
withAuth
Base
connect
Network HoC
Base Component
connect HoC
Auth HoC
Higher Order Component Pattern
78
STEP 05
A Pattern Journey
79
Provider Pattern
PROPS DRILLING
APP
A A
B
C
{
name: “Jay Chung” ,
email: xjkit54780@gmail.com
}
PROPS
PROPS
PROPS
<div>{props.name}</div>
<div>{props.email}</div>
<B {…props} />
<C {…props} />
<A {…props} />
IMPLICITEXPLICIT
APP
A A
B
C
{
name: “Jay Chung” ,
email: xjkit54780@gmail.com
}
PROPS React.createContext
<div>{props.name}</div>
<div>{props.email}</div>
Provider
Consumer
<Consumer>
{(props) => (
)}
</Consumer>
(Render Props)
82
Container Component
STEP 01
Compound Component
STEP 02
Render Props
STEP 03
Higher Order Component
STEP 04
A Pattern Journey
Provider Pattern
STEP 05
83
STEP 6
TrendMicro
https://github.com/trendmicro-frontend
85
1
2
3
4
RECAP
5
Container Component Pattern
Compound Component Pattern
Render Props Pattern
Higher Order Component Pattern
Provider Pattern
86
Controlled
component
Props getters
State reducer pattern
Single element
pattern
PATTERNS COMPARISON
Intuitive Maintainable Flexible Composable Use Cases
Container
Component
Compound
Component
HoC
Render Props
Provider
88
More Use Cases
89
react-redux react-router
90
Provider Pattern
91
Higher Order Component
92
93
Provider Pattern
94
Higher Order
Component
95
Render Props in
React Apollo 2.1
https://spectrum.chat/thread/d2e9ad39-f6b2-4614-ae20-3f619100bb3b
PATTERNS COMPARISON
Intuitive Maintainable Flexible Composable Use Cases
Container
Component ❤❤ ❓ 💢 💢 Any
Compound
Component ❤❤ ❤❤ ❤ 💢
Tab, Nav, Wizard,
Steps
HoC ❤ ❤❤ ❤❤ ❤❤❤
Utility
Component
Render Props ❤ ❤❤ ❤❤❤ ❤
Utility
Component
Provider ❤ ❤❤ ❤ ❤ Theme, i18n
98
thank you
https://github.com/xJkit

More Related Content

What's hot (20)

PDF
Easy automation.py
Iakiv Kramarenko
 
PDF
Easy tests with Selenide and Easyb
Iakiv Kramarenko
 
PPTX
Codeception
少東 張
 
PDF
Unit-testing and E2E testing in JS
Michael Haberman
 
PDF
Polyglot automation - QA Fest - 2015
Iakiv Kramarenko
 
PDF
Codeception: introduction to php testing
Engineor
 
PPTX
Testing React Applications
stbaechler
 
PDF
Codeception
Jonathan Lau
 
PDF
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Iakiv Kramarenko
 
PDF
From Good to Great: Functional and Acceptance Testing in WordPress.
David Aguilera
 
PPTX
Test automation with php codeception
buddhieash
 
PDF
Web ui tests examples with selenide, nselene, selene & capybara
Iakiv Kramarenko
 
PDF
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Iakiv Kramarenko
 
PDF
Testing with Codeception
Jeremy Coates
 
PDF
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Iakiv Kramarenko
 
PDF
Testing Web Applications
Seth McLaughlin
 
PDF
Automation Abstraction Layers: Page Objects and Beyond
Alan Richardson
 
PDF
Selenium Overview
Abhijeet Vaikar
 
PDF
Night Watch with QA
Carsten Sandtner
 
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
Easy automation.py
Iakiv Kramarenko
 
Easy tests with Selenide and Easyb
Iakiv Kramarenko
 
Codeception
少東 張
 
Unit-testing and E2E testing in JS
Michael Haberman
 
Polyglot automation - QA Fest - 2015
Iakiv Kramarenko
 
Codeception: introduction to php testing
Engineor
 
Testing React Applications
stbaechler
 
Codeception
Jonathan Lau
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Iakiv Kramarenko
 
From Good to Great: Functional and Acceptance Testing in WordPress.
David Aguilera
 
Test automation with php codeception
buddhieash
 
Web ui tests examples with selenide, nselene, selene & capybara
Iakiv Kramarenko
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Iakiv Kramarenko
 
Testing with Codeception
Jeremy Coates
 
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Iakiv Kramarenko
 
Testing Web Applications
Seth McLaughlin
 
Automation Abstraction Layers: Page Objects and Beyond
Alan Richardson
 
Selenium Overview
Abhijeet Vaikar
 
Night Watch with QA
Carsten Sandtner
 
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 

Similar to Use React Patterns to Build Large Scalable App (20)

PDF
React Development | Advanced Component Composition Patterns
Inexture Solutions
 
PDF
React HOCs, Context and Observables
Trayan Iliev
 
PDF
Advanced React Component Patterns - ReactNext 2018
Robert Herbst
 
PDF
Learning Patterns Lydia Hallie Addy Osmani Josh W Comeau
fatolukaman
 
PDF
2018 05-16 Evolving Technologies: React, Babel & Webpack
Codifly
 
PDF
Top React Design Patterns for Streamlined Development in 2024
Neil Johnson
 
PPTX
what is context API and How it works in React.pptx
BOSC Tech Labs
 
PDF
React in Action 1st Edition Mark Tielens Thomas
jyliyakainu
 
PPTX
React + Flux = Joy
John Need
 
PDF
Content-Driven Apps with React
Netcetera
 
PPTX
React JS Lecture 10.pptx Our clg lecture
ranjeet2000thakkar
 
PDF
React Context API
NodeXperts
 
PPTX
React patterns
Naimish Verma
 
PDF
Learn reactjs, how to code with example and general understanding thinkwik
Hetaxi patel
 
PDF
React in Action 1st Edition Mark Tielens Thomas
nurizpochun
 
PPTX
How Top React Design Patterns Are Shaping the Development Lifecycle?
mikekelvin0008
 
PDF
2018 02-22 React, Redux & Building Applications that Scale | React
Codifly
 
PDF
React 18 Design Patterns And Best Practices Fourth Edition Early Access 4 Con...
hasiictyy
 
PDF
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
PDF
Patterns For React Application Design
Ian Thomas
 
React Development | Advanced Component Composition Patterns
Inexture Solutions
 
React HOCs, Context and Observables
Trayan Iliev
 
Advanced React Component Patterns - ReactNext 2018
Robert Herbst
 
Learning Patterns Lydia Hallie Addy Osmani Josh W Comeau
fatolukaman
 
2018 05-16 Evolving Technologies: React, Babel & Webpack
Codifly
 
Top React Design Patterns for Streamlined Development in 2024
Neil Johnson
 
what is context API and How it works in React.pptx
BOSC Tech Labs
 
React in Action 1st Edition Mark Tielens Thomas
jyliyakainu
 
React + Flux = Joy
John Need
 
Content-Driven Apps with React
Netcetera
 
React JS Lecture 10.pptx Our clg lecture
ranjeet2000thakkar
 
React Context API
NodeXperts
 
React patterns
Naimish Verma
 
Learn reactjs, how to code with example and general understanding thinkwik
Hetaxi patel
 
React in Action 1st Edition Mark Tielens Thomas
nurizpochun
 
How Top React Design Patterns Are Shaping the Development Lifecycle?
mikekelvin0008
 
2018 02-22 React, Redux & Building Applications that Scale | React
Codifly
 
React 18 Design Patterns And Best Practices Fourth Edition Early Access 4 Con...
hasiictyy
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
Patterns For React Application Design
Ian Thomas
 
Ad

Recently uploaded (20)

PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Import Data Form Excel to Tally Services
Tally xperts
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Ad

Use React Patterns to Build Large Scalable App