11
我在使用核素的原生項目中使用流量0.42.0。StyleSheet.create「不在流程中」
使用默認的項目,我得到以下信息:
隨着以下錯誤:
> 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
,但是這給了我相同的消息(以及來自上面的相同錯誤):
有什麼辦法可以讓我在這裏得到正確的流式打字嗎?
僅供參考,完整的文件是:
/**
* 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
但是原生的源代碼在'create'函數上有流式輸入。見https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/StyleSheet.js –
此外,似乎我不能cmd +點擊創建功能跳轉到它,這表明由於某些原因,該流程不解析原始來源。 –
請參閱編輯。 – Codesingh