I'm doing the ReactNative mobile app. WebApp runs smoothly and everything works. But when I transfer everything to the mobile part, I'm stuck with an error when I enter the text in input field. What I'm doing wrong and what is my mistake? Here is my code:
import React from 'react';
import { StyleSheet, TextInput, View } from 'react-native';
export default class App extends React.Component {
state={
message:"Hi {name}, your rating for this app is {rating}"
}
handleName=()=>{
this.setState({
message:"Hi "+this.refs.name.value+", your rating for this app is {rating}"
})
}
handleRating=()=>{
this.setState({
message:"Hi "+this.refs.name.value+", your rating for this app is "+this.refs.rating.value
})
}
render() {
return (
<View style={styles.container}>
<TextInput
placeholder="Your Name"
ref="name"
onChangeText={this.handleName}
/>
<TextInput
placeholder="Your Rating"
ref="rating"
onChangeText={this.handleRating}
/>
<View>{this.state.message}</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});