React Native Code Reuse
Architecture that Works
Aaron Greenwald
Survey
01 / The Promise
“...that approach yielded around 85% reuse of app code”
- Facebook
“Don’t repeat yourself. It’s not only repetitive, it’s redundant, and people have heard it before.”
- Lemony Snicket
Is it true?
Yes!
(Mostly)
Android & iOS
Web Apps
Other RN Projects
02 / Android & iOS
What CAN'T you share?
Platform-Specific Code
Platform Module
Filename Suffixes
Platform-Specific Code
Platform Module
Filename Suffixes
import InputBox from './InputBox';
Platform-Specific Code
Platform Module
Filename Suffixes
Composition
>
Inheritance
Architecture Matters
Keep logic out of views
Presenters/Dispatchers
Logic should be cross platform
Small & modular views
03 / Web Apps
Architecture Matters
Reusable application logic
Compilation gets complicated
Create a separate module
npm link...
04 / Multiple Projects
Architecture Matters
Binaries
Dependency Hell
Binaries
Dependency Hell
Is it worthwhile?
Architecture Matters
#architecture_matters
aaron@aarongreenwald.com
|
@aaronjgreenwald
|
github.com/aarongreenwald
Icons created by
Dave Gandy
from
www.flaticon.com
and licensed under
CC 3.0 BY