Skip to content

Commit

Permalink
Require expo-linear-gradient just in case the user wants Gradient com…
Browse files Browse the repository at this point in the history
…ponent #5
  • Loading branch information
catalinmiron committed Nov 8, 2019
1 parent 67f9c9b commit 2d6c1d8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 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
Expand All @@ -20,6 +24,7 @@ export default ({ gradient, children, style }) => {
</View>
);
}

return (
<LinearGradient style={style} {...generated[0]}>
{children || null}
Expand Down

0 comments on commit 2d6c1d8

Please sign in to comment.