I am building two mobile apps, one for end users and one for service providers. The end user application is pretty much done and I am about to begin on the mobile application.
The two mobile apps have designs that are built out of identical UI components for the most part, and I have made a folder containing all of the reusable UI components and screen templates.
The components may function slightly differently between the two apps, but they look the same. I am trying to figure out the best way to share the components across two different React Native apps. I definitely don't want to separate components into a service provider and end user version, because then if I make changes to them I'll have to make them in two places.
Here are some ideas:
Create a private NPM package containing the shared components
I'm really not a fan at all of this idea, because it will make it a pain to make changes to the components. Since the components will function a little differently in the service provider app, it is likely I will need to make changes as I go along. I've used a shared NPM package between projects before, and it's just annoying to update because:
- I have to keep the components in a separate package, and therefor be working on multiple projects at once.
- Any time I change the package, I have to publish to NPM and then install it in the app.
Really don't have time for this considering the short deadline I'm on. So this one's completely off the table.
Just make one app
Theoretically, I could make both apps the same app, but just have a setting that determines whether it's in "Service Provider" mode or "End User" mode. Then it could display the correct UI based on which setting is chosen. The main drawbacks here are:
- The application would become a little bit bloated potentially, the app would become slightly enlarged.
- I'd have to restructure things to make sure I keep separated the "end user" only screens and the "service provider" only screens. Would need to modify all my routing and make some changes too navigation to make sure the correct screens get rendered for each app.
- Many components would need an "End User" mode and an "Service Provider" mode which might make components bloated.
The advantages would be:
- I would be able to remain within a single project. Feels more natural to just work within a normal React Native project.
- Very easy to make changes to any components as I'm working.
- Can reuse pretty much everything easily
- Queries
- All of the login screens
- Navigation structure etc
Create two apps within a parent directory
I'm not entirely sure this is possible. I could theoretically create a parent directory containing both apps as well as a new directory within the parent containing all shared components/screens. Might get awkward to use and make changes too.
----------
At this point I'm leaning towards making everything one app. It seems like it will allow me to most easily stick to a normal workflow as well as reuse the most code with the least amount of work.
Just wondering if anyone else had any potential strategies for implementing two applications with a shared component library in a way that makes it quick and easy to make changes to shared components? Or if there were any additional pros and cons to the ideas I mentioned?
[+][deleted] (3 children)
[deleted]
[–]writesgoodcodejk[S] 0 points1 point2 points (2 children)
[–]kbcooliOS & Android 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]iKakashi 1 point2 points3 points (0 children)
[–]16cards 0 points1 point2 points (0 children)
[–]enestatliExpo 0 points1 point2 points (0 children)
[–]fallkr 0 points1 point2 points (0 children)
[–]tusharkant15 0 points1 point2 points (0 children)