admin管理员组文章数量:1022777
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
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
本文标签: reactjsexpolineargradient throws quotProperty 39React39 doesn39t existquot errorStack Overflow
版权声明:本文标题:reactjs - expo-linear-gradient throws "Property 'React' doesn't exist" error - Stack O 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745557212a2155948.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论