Answer the question
In order to leave comments, you need to log in
How to understand the React Native application code, what is going on here?
handleChange = key => val =>
{
this.setState({ [key]: val })
}
<TextInput
placeholder="Логин"
style={styles.input}
value = {this.state.login}
onChangeText = {this.handleChange('login')}
/>
Answer the question
In order to leave comments, you need to log in
You must pass an event handler function to onChangeText
. onChangeText = {this.handleChange('login')}
Here comes the function call handleChange
, which will return a function, which in turn will change the state of the application, receiving key
from the closure (in your example, key = "login"), but val
I don’t know where it will be received from. Maybe it's some kind of React Native feature.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question