Tuesday 29 January 2019

circular dependencies in a react/react-native app

I'm planning on creating an app for web and native mobile using react and react-native. I've looked into how to go about code sharing between these two environments and have not found much useful info. I did come across react-native-web which tries to let you use your native code on the web too, but I'm not really interested in that, I want to write the native stuff using the react-native code and use standard web technologies for the web and I suspect trying to patch the react-native code onto the web would be a nightmare. So instead, I figure I should create 3 modules, one for strictly react-native, one for strictly react, and one for shared code. My only problem is I'm not sure how to deal with the dependencies. I figure the non-shared code should depend on the shared code since the non-shared code would be the entry point. However, I would like to also have component code in the shared code, but at a higher level. For example, if I created some low-level component in the non-shared code which implemented say a basic form (just as an example). Then I want to be able to refer to the correct lower level code at runtime so that on mobile it imports the native form and on the web it imports the web form. So basically I would like the non-shared code to provide dependencies for the shared code when it is imported. Is this possible to do? I haven't done a lot with nodejs modules before, so I'm not sure how to go about doing something like this and what technologies I might need. Thanks for any help.

Submitted January 30, 2019 at 02:45AM by rosebeats1

No comments:

Post a Comment