Po prostu zacząłem uczyć się reagować, więc z góry przepraszam, jeśli to może brzmieć jak głupie pytanie. Próbuję utworzyć prostą stronę iOS za pomocą przycisku, który uruchamia akcję. Śledzę ten tutorial jak zacząć, a to jest mój kod indeksu:Nie mogę znaleźć zmiennej: React
'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);
Problemem jest to, że gdy uruchamiam go z Xcode na moim urządzeniu uzyskać
Can't find variable: React
render
main.jsbundle:1509:6
mountComponent
mountChildren
Próbowałam szukaj w Internecie odpowiedzi, ale nie może znaleźć niczego, co faktycznie pomoże. Masz pojęcie, jaki może być problem?
spróbuj uruchomić swój projekt z 'reagować-rodzimej start' lub' reagować-rodzimy run-ios' poleceń – semanser
I wypróbowany i wyświetla ten sam komunikat o błędzie – KeykoYume
jaka jest Twoja natywna wersja reagowania? – QoP