Slide 1

Slide 1 text

Architecture that Works React Native Code Reuse Aaron Greenwald github.com/aarongreenwald @aaronjgreenwald [email protected]

Slide 2

Slide 2 text

01 / The Promise

Slide 3

Slide 3 text

“...that approach yielded around 85% reuse of app code” - Facebook

Slide 4

Slide 4 text

“...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

Slide 5

Slide 5 text

Is it true?

Slide 6

Slide 6 text

Yes!

Slide 7

Slide 7 text

(Mostly)

Slide 8

Slide 8 text

Android & iOS

Slide 9

Slide 9 text

Web Apps Android & iOS

Slide 10

Slide 10 text

Web Apps Other RN Projects Android & iOS

Slide 11

Slide 11 text

02 / Android & iOS

Slide 12

Slide 12 text

Platform-Specific Code Platform Module Conditional statements in code

Slide 13

Slide 13 text

Platform-Specific Code Filename Suffixes Separate files per platform

Slide 14

Slide 14 text

Composition > Inheritance

Slide 15

Slide 15 text

Platform-Specific Code Platform Module Conditional statements in code Filename Suffixes Separate files per platform

Slide 16

Slide 16 text

Architecture Matters

Slide 17

Slide 17 text

Keep logic out of views

Slide 18

Slide 18 text

Presenters/Dispatchers Keep logic out of views

Slide 19

Slide 19 text

Presenters/Dispatchers Logic should be cross-platform Keep logic out of views

Slide 20

Slide 20 text

Presenters/Dispatchers Logic should be cross-platform Keep logic out of views Small & modular views

Slide 21

Slide 21 text

03 / Web Apps

Slide 22

Slide 22 text

Architecture Matters

Slide 23

Slide 23 text

Reusable application logic

Slide 24

Slide 24 text

Compilation gets complicated Reusable application logic

Slide 25

Slide 25 text

Create a separate module Compilation gets complicated Reusable application logic

Slide 26

Slide 26 text

Create a separate module Compilation gets complicated Reusable application logic npm link...

Slide 27

Slide 27 text

04 / Multiple Projects

Slide 28

Slide 28 text

Architecture Matters

Slide 29

Slide 29 text

Binaries

Slide 30

Slide 30 text

Dependency Hell Binaries

Slide 31

Slide 31 text

Is it worthwhile? Dependency Hell Binaries

Slide 32

Slide 32 text

Architecture Matters

Slide 33

Slide 33 text

#architecture_matters github.com/aarongreenwald @aaronjgreenwald [email protected]