ARMATAV
ARMATAV

Reputation: 634

React Native TextInput not updating state

Well this is an embarrassing question, but I can't get this TextInput to take values I type into it.

It just deletes it as fast as I can type it - and I'm pretty sure logging this.state.code shows an empty variable.

Is it the keyboard type messing with me? Do I need to do a .toString()?

constructor() {
    super()
    this.state = {
        code: '12'
    }
}

<TextInput
    onChangedText={(text) => this.setState({code: text})}
    value={this.state.code}
    keyboardType='numeric'
    style={styles.input}
    placeholder='Code'
    maxLength={4}
/>

Upvotes: 3

Views: 1502

Answers (1)

wvicioso
wvicioso

Reputation: 538

The correct prop is onChangeText. Not onChangedText

Upvotes: 3

Related Questions