alimek
alimek

Reputation: 23

ReactNative - Many apps on same JS code

I have new challange to solve. We would like to create many application with same JS code and base on parameter load different theme and maybe do some extra things for specified value. This I guess is not a problem by adding a parameter at build process and just check it while render.

Question is how to deal with this on native code. I was thinking about copy&paste ios/andoroid code and change all required parameters, name etc, but it sounds like not best approach. Do anyone have idea how to deal with this problem ?

Thanks in advance for help.

Upvotes: 0

Views: 171

Answers (1)

Phil Plückthun
Phil Plückthun

Reputation: 1439

I’d suggest you to create a component library that exports shared components for reusability.

For theming you could use the theming library that distributes a theme object in the context including subscriptions to changes. https://www.npmjs.com/package/theming

Libraries like styled-components and glamorous-native already have this built into them.

One thing to note is that you shouldn’t forget to use peerDependencies while pulling all reused dependencies into devDependencies so that you won’t end up with duplicated packages in any case.

Upvotes: 1

Related Questions