0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for answer, but problem is not in JS code but native. If dont want to do npm link every time when i add new library for example in 50 applications. I would do it once and somehow share this.
I found that in Xcode i can add many Targets and link some files related to project only to that Target like icons and SplashScreen. Not sure if is there any similar option for Android ?
@alimek I think for Android you can write a gradle file and include it into your main one. Another addition would be to maybe write a boilerplate or a React-Native-scripts package?
problem is solved, on android i use Flavours to handle this problem ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.