2017-05-07 6 views
11

私は核種と反応したネイティブプロジェクトでフロー0.42.0を使用しています。デフォルトのプロジェクトではStyleSheet.create "流れに覆われていません"

、私は次のメッセージが出ます:次のエラーとともに

enter image description here

を:

> flow check 
index.ios.js:40 
40:    <View style={style.container}> 
            ^^^^^^^^^ property `container`. Property cannot be accessed on possibly undefined value 
40:    <View style={style.container}> 
           ^^^^^ undefined 

index.ios.js:40 
40:    <View style={style.container}> 
            ^^^^^^^^^ property `container`. Property not found in 
40:    <View style={style.container}> 
           ^^^^^ Array 

index.ios.js:41 
41:     <Text style={style.welcome}> 
             ^^^^^^^ property `welcome`. Property cannot be accessed on possibly undefined value 
41:     <Text style={style.welcome}> 
            ^^^^^ undefined 

index.ios.js:41 
41:     <Text style={style.welcome}> 
             ^^^^^^^ property `welcome`. Property not found in 
41:     <Text style={style.welcome}> 
            ^^^^^ Array 

index.ios.js:44 
44:     <Text style={style.instructions}> 
             ^^^^^^^^^^^^ property `instructions`. Property cannot be accessed on possibly undefined value 
44:     <Text style={style.instructions}> 
            ^^^^^ undefined 

index.ios.js:44 
44:     <Text style={style.instructions}> 
             ^^^^^^^^^^^^ property `instructions`. Property not found in 
44:     <Text style={style.instructions}> 
            ^^^^^ Array 

index.ios.js:47 
47:     <Text style={style.instructions}> 
             ^^^^^^^^^^^^ property `instructions`. Property cannot be accessed on possibly undefined value 
47:     <Text style={style.instructions}> 
            ^^^^^ undefined 

index.ios.js:47 
47:     <Text style={style.instructions}> 
             ^^^^^^^^^^^^ property `instructions`. Property not found in 
47:     <Text style={style.instructions}> 
            ^^^^^ Array 


Found 8 errors 

この問題(https://github.com/flowtype/flow-typed/issues/631は)正しいタイプだったことを示唆しているように見えましたStyleSheet.Stylesですが、それは私に同じメッセージ(上記と同じエラー)を与えます:

enter image description here

ここで適切なフロータイピングができる方法はありますか?参考のため

、完全なファイルは次のとおりです。

/** 
* Sample React Native App 
* https://github.com/facebook/react-native 
* @flow 
*/ 

import React, { Component } from 'react'; 
import { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    View 
} from 'react-native'; 

export default class PartalkReact extends Component { 
    render() { 
     return (
      <View style={styles.container}> 
       <Text style={styles.welcome}> 
        Welcome to React Native! 
       </Text> 
       <Text style={styles.instructions}> 
        To get started, edit index.ios.js 
       </Text> 
       <Text style={styles.instructions}> 
        Press Cmd+R to reload,{'\n'} 
        Cmd+D or shake for dev menu 
       </Text> 
      </View> 
     ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
    backgroundColor: '#F5FCFF', 
    }, 
    welcome: { 
    fontSize: 20, 
    textAlign: 'center', 
    margin: 10, 
    }, 
    instructions: { 
    textAlign: 'center', 
    color: '#333333', 
    marginBottom: 5, 
    }, 
}); 

AppRegistry.registerComponent('PartalkReact',() => PartalkReact); 

編集 0.45.0を流れるようにアップグレードした後、コメントどおり、私はもはや私のファイルに問題を抱えているが、反応自体はで失敗しません次のエラーが発生しました:https://pastebin.com/raw/Ngpagayi

答えて

2

警告はサードパーティがフローを最後まで統合していないためです。私たちの場合、StyleSheetは警告を出すので、ネイティブの反応はフローを統合していないサードパーティーになります。反応するネイティブは、一部のコンポーネントに含まれるフローのみがコアとなり、正式に宣言されました。

import type { StyleObj } from 'react- 
native/Libraries/StyleSheet/StyleSheetTypes'; 

type Props = { 
    style?: StyleObj, 
}; 

他の方法は、フローをアップグレードすることです:私は結論に達しましたので、その反応-ネイティブはスタイルシートで流れを使用しているあなたに言われたよう

乾杯:)

+0

しかし、インクルードは、ネイティブソースが 'create'機能に流れタイピングを持って反応します。 https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/StyleSheet.js –

+0

も参照してください。また、作成機能にcmd +クリックすることはできないようですそのフローは何らかの理由で反応したネイティブソースを解析していません。 –

+0

編集内容をご覧ください。 – Codesingh

関連する問題