react-native-skeleton-placeholder icon indicating copy to clipboard operation
react-native-skeleton-placeholder copied to clipboard

Expo Support?

Open bfarrgaynor opened this issue 3 years ago • 9 comments

When running this on an Expo managed project I get a BVLinearGradient was not found in the UIManager error. Is it possible to work around this? It looks like the issue has to do with react-native-linear-gradient. Is it possible to swap this dependency for expo-linear-gradient? Has anyone got this working in expo?

bfarrgaynor avatar Aug 26 '21 16:08 bfarrgaynor

I've ended up using https://github.com/mfrachet/rn-placeholder

oldo avatar Aug 27 '21 02:08 oldo

@bfarrgaynor +1 tried rebuilding the app as suggested by some stackoverflow answers but that didn't help. the error happens only when i use the <SkeletonPlaceholder></SkeletonPlaceholder>

Devs, Let me know if you need any details abt my environment setup

suraj-ingle avatar Sep 07 '21 21:09 suraj-ingle

Same. The exact error: Invariant Violation: requireNativeComponent: "BVLinearGradient" was not found in the UIManager.

ftzi avatar Sep 20 '21 02:09 ftzi

Any news on Expo support?

ansmlc avatar May 02 '22 02:05 ansmlc

I've ended up using https://github.com/mfrachet/rn-placeholder

That package costed me a lot of problems, I ended up using rn-placeholder too, it is simple and works fine in both IOS & Android

soltaneben avatar Jun 23 '22 12:06 soltaneben

expo-linear-gradient and react-native-linear-gradient have very similar (the same?) APIs, so one potential approach at getting this package to work with expo is to apply a patch to react-native-skeleton-placeholder as follows:

diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
index 95b995a..80e7540 100644
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 const masked_view_1 = __importDefault(require("@react-native-masked-view/masked-view"));
 const React = __importStar(require("react"));
 const react_native_1 = require("react-native");
-const react_native_linear_gradient_1 = __importDefault(require("react-native-linear-gradient"));
+const react_native_linear_gradient_1 = require("expo-linear-gradient");
 const WINDOW_WIDTH = react_native_1.Dimensions.get('window').width;
 const logEnabled = false;
 const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E9EE', highlightColor = '#F2F8FC', speed = 800, direction = 'right', borderRadius, }) => {
@@ -83,7 +83,7 @@ const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E
       <react_native_1.View style={[react_native_1.StyleSheet.absoluteFill, { backgroundColor }]}/>
 
       {isAnimationReady && highlightColor !== undefined && transparentColor !== undefined && (<react_native_1.Animated.View style={animatedGradientStyle}>
-          <react_native_linear_gradient_1.default {...gradientProps} colors={[transparentColor, highlightColor, transparentColor]}/>
+          <react_native_linear_gradient_1.LinearGradient {...gradientProps} colors={[transparentColor, highlightColor, transparentColor]}/>
         </react_native_1.Animated.View>)}
     </masked_view_1.default>);
 };

Apply the patch using patch-package. We're doing this in production with no issues.

djw27 avatar Nov 11 '22 15:11 djw27

I believe you have to use the dev-client. https://docs.expo.dev/development/create-development-builds/

This creates a client that allows BVLinearGradient to be registered

NabeelUppel avatar Mar 25 '23 14:03 NabeelUppel

expo-linear-gradient and react-native-linear-gradient have very similar (the same?) APIs, so one potential approach at getting this package to work with expo is to apply a patch to react-native-skeleton-placeholder as follows:

diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
index 95b995a..80e7540 100644
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 const masked_view_1 = __importDefault(require("@react-native-masked-view/masked-view"));
 const React = __importStar(require("react"));
 const react_native_1 = require("react-native");
-const react_native_linear_gradient_1 = __importDefault(require("react-native-linear-gradient"));
+const react_native_linear_gradient_1 = require("expo-linear-gradient");
 const WINDOW_WIDTH = react_native_1.Dimensions.get('window').width;
 const logEnabled = false;
 const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E9EE', highlightColor = '#F2F8FC', speed = 800, direction = 'right', borderRadius, }) => {
@@ -83,7 +83,7 @@ const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E
       <react_native_1.View style={[react_native_1.StyleSheet.absoluteFill, { backgroundColor }]}/>
 
       {isAnimationReady && highlightColor !== undefined && transparentColor !== undefined && (<react_native_1.Animated.View style={animatedGradientStyle}>
-          <react_native_linear_gradient_1.default {...gradientProps} colors={[transparentColor, highlightColor, transparentColor]}/>
+          <react_native_linear_gradient_1.LinearGradient {...gradientProps} colors={[transparentColor, highlightColor, transparentColor]}/>
         </react_native_1.Animated.View>)}
     </masked_view_1.default>);
 };

Apply the patch using patch-package. We're doing this in production with no issues.

Just a little change is needed for the updated react-native-skeleton-placeholder library 5.2.4. Updated patch here

diff --git a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
index 353abb6..f019b00 100644
--- a/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
+++ b/node_modules/react-native-skeleton-placeholder/lib/skeleton-placeholder.js
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 const masked_view_1 = __importDefault(require("@react-native-masked-view/masked-view"));
 const React = __importStar(require("react"));
 const react_native_1 = require("react-native");
-const react_native_linear_gradient_1 = __importDefault(require("react-native-linear-gradient"));
+const react_native_linear_gradient_1 = require("expo-linear-gradient");
 const WINDOW_WIDTH = react_native_1.Dimensions.get('window').width;
 const logEnabled = false;
 const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E9EE', highlightColor = '#F2F8FC', speed = 800, direction = 'right', borderRadius, shimmerWidth, }) => {
@@ -86,7 +86,7 @@ const SkeletonPlaceholder = ({ children, enabled = true, backgroundColor = '#E1E
       <react_native_1.View style={[react_native_1.StyleSheet.absoluteFill, { backgroundColor }]}/>
 
       {isAnimationReady && highlightColor !== undefined && transparentColor !== undefined && (<react_native_1.Animated.View style={animatedGradientStyle}>
-          <react_native_linear_gradient_1.default {...getGradientProps(shimmerWidth)} colors={[transparentColor, highlightColor, transparentColor]}/>
+        <react_native_linear_gradient_1.LinearGradient {...getGradientProps(shimmerWidth)} colors={[transparentColor, highlightColor, transparentColor]}/>
         </react_native_1.Animated.View>)}
     </masked_view_1.default>);
 };

After updating the file, run the following command npx patch-package react-native-skeleton-placeholder // install patch-package if not installed Then install postinstall-postinstall and add "postinstall": "patch-package" to your package.json scripts.

samiul-bs avatar Apr 03 '23 07:04 samiul-bs

use expo-react-native-skeleton-placeholder it's work for me 100% similar to react-native-skeleton-placeholder and working in expo

FawadAhmedRaza avatar Nov 11 '23 11:11 FawadAhmedRaza