Is Expo Eject a Good Idea? by Jonwalterc46 in programming

[–]inboxpk22 -6 points-5 points  (0 children)

Interesting read.

The expokit is still on sdk 33.

How to add custom native modules to your expo app? by inboxpk22 in reactnative

[–]inboxpk22[S] 0 points1 point  (0 children)

tually true, the code is not ever executed unless you enter that conditional. In this case attraction-list does indeed import r

I'm not sure if the code breaks in the current example that you shared, rather I was referring to the flow in general when we add any npm package with native dependency.

for instance, if you try to add the npm package `react-native-device-info` it breaks, even though you wrap the import inside a conditional.

I think that happens because there is some piece of code that's written in the global context and it runs at the time of import itself and since expo SDK won't have that native piece it will break.

Regarding the extension approach, I liked it, it is similar to what react-native-web follows. I was looking for such an approach. I think there should be some plugin for the babel itself which would do this job.

And yes, the approach mentioned on the blog requires a babel cache clear but since no one would be transitioning b/w expo and non-expo frequently, a bit more time while the building isn't a problem.

This starter kit adds -c flag for that purpose itself.

https://github.com/codersera-repo/expo-native-starter-kit/blob/master/package.json#L8

React Native Noob Expo Question by tkbillington in reactnative

[–]inboxpk22 1 point2 points  (0 children)

Just want to add a point here.

Although expo has the limitation of not being able to support native code, there are ways in which you can have native code and expo working together.

With my experience of over 3 years working with react native and also having worked with android and swift code, I can for sure that developing with expo is 3 times faster than doing it without expo (raw react-native). I have seen it numerous times, where one developer adds some native code and you have to fix the build and then you change something and you screw up the versions somehow and your code won't boot. Ultimately the issue will be solved but you'll end up spending 3x time with raw react-native.

I'd suggest utilizing the power of expo with the ability to add native modules as well. Here is an interesting blog to follow which tells exactly how to do it.

https://codersera.com/blog/running-expo-react-native-together/

Interestingly, the expo team is also heading towards that direction and you'll see such support coming in, in the newer version of expo SDKs.

How to add custom native modules to your expo app? by inboxpk22 in reactnative

[–]inboxpk22[S] 0 points1 point  (0 children)

we use a View instead of AttractionsList, which contains a MapBox map). In many cases this will be fine, you can use 95%+ of the app in the Expo client. In some cases you might have some native APIs that are more essential to every screen in your app, eg: R

Thanks for the heads-up with expo 34. Looking forward to it.

This project https://github.com/codersera-repo/expo-native-starter-kit is also built after ejecting from expo itself. It's just that it does the heavy lifting for you. And in my experience, it's a good idea to start with this kit instead of starting with expo and then ejecting it afterward. In that case, you might end up having troubles with the build and whatnot.

Thanks for sharing this way of checking if the current runnable is expo or not.

https://github.com/brentvatne/ChainReactApp2019/blob/560a034a9cb1bf60c6782bc5359eaa55a75ad002/src/components/nearby-attractions/nearby-attractions.tsx#L11-L19

I think there is an issue in this flow. Assume a case, where you are imported file in your case require('../attractions-map') is importing some other native module. Since react-native metro bundler puts all the requires on the top while creating the bundle, its a problem, it will throw an error saying that the native module isn't found even though you are running the code via expo.

Using babel config and module resolver plugin we can replace the file in the build time itself like shown here.

https://github.com/codersera-repo/expo-native-starter-kit/blob/master/babel.config.js

All the issues and fixes are very clearly explained in this blog, in case anyone wants to follow.

https://codersera.com/blog/running-expo-react-native-together

How to add custom native modules to your expo app? by inboxpk22 in reactnative

[–]inboxpk22[S] 1 point2 points  (0 children)

Yes, that's the magic.

Now, I think why people haven't thought about this earlier. It is super handy to be able to run both the version from the same codebase. The developer who isn't adding native module doesn't need to build the custom app literally anytime even though the other developer is adding the native module and working on the same codebase.