I wrote a React app which used a 3rd party library and had no issues. I am now trying to write the equivalent app in React-Native (as a learning exercise) and I am running into an error as soon as I try and call an API in the 3rd party library.
I am on a windows machine and have react versions
- "react": "16.9.0",
- "react-native": "0.61.5",
Error
The error I am seeing in the window showing the metro builder has
error: bundling failed: src\scripts\my3rdPartyLib.js: src\scripts\my3rdPartyLib.js:Invalid call at line 121:
require([something], function (....
In my Android emulator I am seeing
The development server returned response error code : 500
Note: It also fails if i have the library coming from node-modules as apposed to copying it into my "scripts" folder.
What I have tried
As per a thread on SO i uninstalled babel-preset-react-native and then installed it.
npm un -D babel-preset-react-native
npm i -D babel-preset-react-native@2.1.0
Afterwards I realised as I am on version 61 it uses "metro-react-native-babel-preset", my babel.config.js contains the following
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
Does anyone have an idea how I can get the use of the 3rd party library working in my react-native app?