React-native-linear-gradient: Flow Error on style prop

Created on 4 Feb 2019  ยท  2Comments  ยท  Source: react-native-linear-gradient/react-native-linear-gradient

Hello,

I'm running into a Flow issue with the following component:

// @flow
import React from 'react';
import { TouchableWithoutFeedback } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import styles from './styles';

const defaultGradientColours = ['#33000000', '#00B2D6'];
const gradientColours = defaultGradientColours;

const Background = () => (
  <TouchableWithoutFeedback onPress={this.onPress}>
    <LinearGradient colors={gradientColours} style={styles.backgroundGradient} />
  </TouchableWithoutFeedback>
);

export default Background;

The error message is:

Cannot create LinearGradient element because property style is missing in object type [1] but exists in props [2].

     src/Background.js
     13โ”‚
     14โ”‚ const Background = () => (
     15โ”‚   <TouchableWithoutFeedback onPress={() => dependencies.Analytics.headerPressed()}>
 [2] 16โ”‚     <LinearGradient colors={gradientColours} style={styles.backgroundGradient} />
     17โ”‚   </TouchableWithoutFeedback>
     18โ”‚ );
     19โ”‚

     node_modules/react-native-linear-gradient/common.js
 [1]  8โ”‚ export type Props = $Exact<{
      9โ”‚   start?: Point;
     10โ”‚   end?: Point;
     11โ”‚   colors: string[];
     12โ”‚   locations?: number[];
     13โ”‚   useAngle?: boolean;
     14โ”‚   angleCenter?: Point;
     15โ”‚   angle?: number;
     16โ”‚ }> & typeof(View);

It seems that Flow isn't able to derive the type declaration of View in the union of Props and typeof(View).

I'm not sure if I'm missing anything out of the ordinary.
Here are the dependencies:

  • react-native-linear-gradient: ^2.5.3
  • flow-bin: ^0.78.0

I'm happy to look into this issue and contribute if needed be.

Most helpful comment

This issue is still valid in the last version 2.5.6

All 2 comments

I'm happy to look into this issue and contribute if needed be

@RCiesielczuk Please do! I'll be happy to review and merge a PR :)

This issue is still valid in the last version 2.5.6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moiri-gamboni picture moiri-gamboni  ยท  4Comments

khachik picture khachik  ยท  4Comments

hopperhuang picture hopperhuang  ยท  4Comments

jcbiznoff picture jcbiznoff  ยท  4Comments

acollazomayer picture acollazomayer  ยท  4Comments