From 2d6c1d8275bacc3a52f182c59e63d2d28fb2d0d8 Mon Sep 17 00:00:00 2001 From: catalinmiron Date: Fri, 8 Nov 2019 11:56:05 +0100 Subject: [PATCH] Require expo-linear-gradient just in case the user wants Gradient component #5 --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8186851..26835af 100755 --- a/index.js +++ b/index.js @@ -1,11 +1,15 @@ import React from "react"; import { View, StyleSheet } from "react-native"; import generateGradient from "./generator"; -import { LinearGradient } from "expo-linear-gradient"; export { generateGradient }; export default ({ gradient, children, style }) => { + // Avoid breaking this when people are not using expo :) + // find a better solution to expose either expo-linear-gradient or + // react-native-linear-gradient. + const { LinearGradient } = require("expo-linear-gradient"); + const generated = generateGradient(gradient, { width: style.width, height: style.height @@ -20,6 +24,7 @@ export default ({ gradient, children, style }) => { ); } + return ( {children || null}