Hi. I was wondering what would be the steps required if I wanted to support a react-native library that requires native code/linking, without ejecting?
Would I have to create my own Expo module, and would it require some approval from the Expo team?
The library I really need is GitHub - joltup/rn-fetch-blob: A project committed to making file access and data transfer easier, efficient for React Native developers. for uploading blobs.
I think your options are basically:
- Eject; or
- Convince the Expo team to add the library to future versions of Expo
Of course adding stuff to Expo is not done lightly because everybody who does not need the library would still it included, making their apps a little bigger.
Gotcha, but that shouldn’t be the case if it is its own module, e.g. expo-rn-fetch-blob?
No, it’s no different to any of the other modules with native code that Expo includes (unless I’m missing something). I mean, in some cases they might have made some modifications to the code to make it work better in the Expo client, I suppose, but for something like
rn-fetch-blob I don’t think that would be necessary.
If you’re not using Expo you need to install it (possibly using
react-native link depending on your version of React Native). But the Expo team has done this already, so everybody using the Managed Workflow can just use
react-native-screens or other things that depend on it (e.g. React Navigation). But if for some reason you didn’t need
react-native-screens you’re still stuck with it taking up space in your app.
i.e. as far as I understand it, native code in a React Native app is basically either linked in or not. If it’s linked in you can use it. If it’s not, you can’t. I don’t think there’s anything like a module you can dynamically link in (like a plugin or KEXT or Linux kernel module etc.) after the native code is already compiled, which I think would be required for what you’re thinking of.
The Expo team is working to allow customising builds of standalone apps which would, I think, make it much easier to add things in without everybody paying the price.
They’re also working to make it much less painful to eject.
I don’t know when the above will be ready, but things should be closer when SDK 37 is released (planned for 31 March AFAIK.)
I really appreciate the detailed answer, this seems much more complex issue than I anticipated.
The main reason I (and others) need
rn-fetch-blob is because
fetch is very limited, it doesn’t support progress and it doesn’t seem to handle large files well.
rn-fetch-blob can handle chunks and other things with ease in regards to downloading and uploading blobs.
I’ve seen many issues in
rn-fetch-blob where people have tried using it in their Expo project, without success. Issues · joltup/rn-fetch-blob · GitHub
rn-fetch-blob implements native code, and so it cannot be used in expo based projects. You would need to eject from expo from my understanding
rn-fetch-blob would be very valuable library for Expo. Hopefully there will be an easier way to add libraries with native code in the future. I think my best option is to eject at this time in order to unblock the development of my app, and hopefully un-eject in the near future.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.