TL;DR
- Check android/app/build.gradle
- Search your project for: enableHermes
- Change to: true
- Clean and Rebuild project
My default:
project.ext.react = [
enableHermes: false, // clean and rebuild if changing
]
Changed to:
project.ext.react = [
enableHermes: true, // clean and rebuild if changing
]
I am also facing this issue. It works fine on iOS but with Android, it throws an error.
As suggested by the first comment to OP question, @Krismu, I check if Hermes is enabled. Hermes is a Javascript engine that is bundled with React-native to ensure compatibility and efficiency.
React-native documentation says that is enabled by default and you can opt out.
https://reactnative.dev/docs/hermes#switching-back-to-javascriptcore
However, my android/app/build.gradle file was set to false by default, making my android app not use Hermes.
This solved the problem for me. No need to polyfill, use just 'replace()' or change any code for that matter...
Verison info:
- "react": "18.0.0",
- "react-native": "0.69.7",