1

ユーザーが使用している OS に基づいてコードのスニペットを使用する関数を作成しようとしています。これが私の機能です:

linearGradient: function() {
  if( Platform.OS == "android" ){
    return (
      <LinearGradient
        start={[0.0, 0]} end={[0.0, 1]}
        locations={[0,1]}
        colors={['rgba(255, 255, 255, 0.2)', 'rgba(255, 255, 255, 1)']}
        style={styles.linearGradient}>
      </LinearGradient>
    )
  }
  else{
    return (
      <LinearGradient
        start={[0.0, 0.6]} end={[0.0, .94]}
        locations={[0,1]}
        colors={['rgba(255, 255, 255, 0.2)', 'rgba(255, 255, 255, 1)']}
        style={styles.linearGradient}>
      </LinearGradient>
    )
  }
},

ここで私はそれを呼んでいます:

<Image source={{ uri: this.props.thumbnail_img }} style={styles.thumbImg} defaultSource={Images.getImage('black')}>
    {this.linearGradient()}
 </Image>

私が得ているエラーは

「未処理の Promise Rejection の可能性 (id:0): null はオブジェクトではありません」

Android シミュレーターに表示されるエラー:

Android Simulator に表示されるエラー

高度なご協力ありがとうございます。

4

0 に答える 0