여기에 일부 서식 기능과 텍스트 입력을 렌더링해야 내가 React's Native website에서 복사 한 코드입니다 :는 기본 공식 예를 반작용
import React, { Component } from 'react';
import { AppRegistry, Text, TextInput, View } from 'react-native';
export default class PizzaTranslator extends Component {
constructor(props) {
super(props);
this.state = {text: ''};
}
render() {
return (
<View style={{padding: 10}}>
<TextInput
style={{height: 40}}
placeholder="Type here to translate!"
onChangeText={(text) => this.setState({text})}
/>
<Text style={{padding: 10, fontSize: 42}}>
{this.state.text.split(' ').map((word) => word && '').join(' ')}
</Text>
</View>
);
}
}
// skip this line if using Create React Native App
AppRegistry.registerComponent('AwesomeProject',() => PizzaTranslator);
내가 create-react-native-app을 사용하고가. 내가 실행하는 경우
npm run flow
그것은 많은 오류가 표시
내 질문입니다 - 내가 여기서 뭔가 잘못하고있는 중이거나 이미 오래된의 반작용 웹 사이트의 코드를?
App.js:7
7: constructor(props) {
^^^^^ parameter `props`. Missing annotation
App.js:9
9: this.state = {text: ''};
^^^^^^^^^^ object literal. This type is incompatible with
6: export default class PizzaTranslator extends Component {
^^^^^^^^^ undefined. Did you forget to declare type parameter `State` of identifier `Component`?
App.js:18
18: onChangeText={(text) => this.setState({text})}
^^^^^^^^^^^^^^^^^^^^^ call of method `setState`
18: onChangeText={(text) => this.setState({text})}
^^^^^^ property `text` of object literal. Property cannot be assigned on possibly undefined value
6: export default class PizzaTranslator extends Component {
^^^^^^^^^ undefined. Did you forget to declare type parameter `State` of identifier `Component`?
App.js:21
21: {this.state.text.split(' ').map((word) => word && '').join(' ')}
^^^^ property `text`. Property cannot be accessed on possibly undefined value
21: {this.state.text.split(' ').map((word) => word && '').join(' ')}
^^^^^^^^^^ undefined. Did you forget to declare type parameter `State` of identifier `Component`?
Found 4 errors
import React, { Component } from 'react';
import { AppRegistry, Text, TextInput, View } from 'react-native';
export default class PizzaTranslator extends Component {
constructor(props) {
super(props);
this.state = {text: ''};
}
render() {
return (
<View style={{padding: 10}}>
<TextInput
style={{height: 40}}
placeholder="Type here to translate!"
onChangeText={(text) => this.setState({text})}
/>
<Text style={{padding: 10, fontSize: 42}}>
{this.state.text.split(' ').map((word) => word && '').join(' ')}
</Text>
</View>
);
}
}
// skip this line if using Create React Native App
AppRegistry.registerComponent('AwesomeProject',() => PizzaTranslator);
흐름 구문에 따라 변경해야 할 수도 있습니다. btw 프로젝트 루트 디렉토리 이름은 무엇입니까 –
@ JigarShah 디렉토리 이름은 피자입니다. – valk
확인할 Flow 유형이 없으면 Flow를 실행하는 이유는 무엇입니까? 그리고 어쨌든 복사 된 예제 코드에서 유형 검사기를 실행하는 이유는 무엇입니까? 예제를 건너 뛰기 만하면됩니다. 그것도 지침에 없습니다. 아주 기초를 배우고 싶다면 실제로해야 할 단계에 충실해야합니다. –