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 you share?
What CAN'T you share?
But How?
Platform-Specific Code
Platform Module
Platform-Specific Code
Filename Suffixes
                
import InputBox from './InputBox';
                
            
Platform-Specific Code
Platform Module
Filename Suffixes
Composition > Inheritance
Architecture Matters
Logic should be cross platform
Keep logic out of views
Presenters/Dispatchers
HOCs, Hooks, ${new_cool_thing}
Small & Modular Views
03 / Web Apps
Architecture Matters
Completely separate UI
Create a separate module
Reusable application logic
Compilation gets complicated
npm/yarn link...
04 / Multiple Projects
Architecture Matters
Binaries
Dependency Hell
Is it worth it?
Architecture Matters
#architecture_matters