Я только начал учиться реагировать, поэтому заранее извиняюсь, если это может показаться глупым вопросом. Я пытаюсь создать простую страницу iOS с кнопкой, которая запускает действие. Я последовал за учебником о том, как начать работу, и это мой индексный код:
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
TouchableHighlight,
Component,
AlertIOS // Thanks Kent!
} = React;
class myProj extends Component {
render() {
return (
<View style={styles.container}>
<Text>
Welcome to React Native!
</Text>
<TouchableHighlight style={styles.button}
onPress={this.showAlert}>
<Text style={styles.buttonText}>Go</Text>
</TouchableHighlight>
</View>
);
}
showAlert() {
AlertIOS.alert('Awesome Alert', 'This is my first React Native alert.', [{text: 'Thanks'}] )
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFFFFF'
},
buttonText: {
fontSize: 18,
color: 'white',
alignSelf: 'center'
},
button: {
height: 44,
flexDirection: 'row',
backgroundColor: '#48BBEC',
alignSelf: 'stretch',
justifyContent: 'center'
}
});
AppRegistry.registerComponent('myProj', () => myProj);
Проблема в том, что когда я запускаю его из Xcode на моем устройстве, я получаю
Can't find variable: React
render
main.jsbundle:1509:6
mountComponent
mountChildren
Я попытался найти в Интернете ответ, но не смог найти ничего, что действительно помогло бы. Любая идея, что может быть проблемой здесь?