After I updated from [email protected]
to [email protected]
the expo-linear-gradient
library started throwing Render Error: Property 'React' doesn't exist
and ReferenceError: Property 'React' doesn't exist
.
This is how I use LinearGradient
in my components:
<LinearGradient
colors={["rgba(0,0,0,0.0)", `rgba(0,0,0,${gradientBottomOpacity})`]}
style={$gradient}
/>
Everything was working well before the update.
I believe it have something to do with how the expo-linear-gradient
imports React
. In the package's NativeLinearGradient.android.tsx
component it import the React as import * as React from 'react'
.
I tried adding { useTransformReactJSXExperimental: true }
in babel.config.js
in presets
const plugins = [
[
"@babel/plugin-proposal-decorators",
{
legacy: true,
},
],
["@babel/plugin-proposal-optional-catch-binding"],
[
"@babel/plugin-transform-private-methods",
{
loose: true, // Ensure 'loose' mode is set otherwise it will throw an error on starting the server
},
],
[
"@babel/plugin-transform-private-property-in-object",
{
loose: true, // Ensure 'loose' mode is set otherwise it will throw an error on starting the server
},
],
"react-native-reanimated/plugin", // NOTE: this must be last in the plugins
]
const vanillaConfig = {
presets: ["module:metro-react-native-babel-preset"],
env: {
production: {},
},
plugins,
}
const expoConfig = {
presets: [["babel-preset-expo", { useTransformReactJSXExperimental: true }]],
env: {
production: {},
},
plugins,
}
let isExpo = false
try {
const Constants = require("expo-constants")
// True if the app is running in an `expo build` app or if it's running in Expo Go.
isExpo =
Constants.executionEnvironment === "standalone" ||
Constants.executionEnvironment === "storeClient"
} catch {}
const babelConfig = isExpo ? expoConfig : vanillaConfig
module.exports = babelConfig