Skip to content

Instantly share code, notes, and snippets.

@chuyihuang
Last active October 26, 2017 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuyihuang/4c64473e315e274153fe8fb3625f832c to your computer and use it in GitHub Desktop.
Save chuyihuang/4c64473e315e274153fe8fb3625f832c to your computer and use it in GitHub Desktop.
clear input on submit example
import React, {Component} from 'react';
import {View, TextInput, Button} from 'react-native';
class App extends Component {
state = {
value: null
}
onSubmit = () => {
this.setState({
value: null
})
}
render() {
return (
<View>
<TextInput
value={this.state.value}
onChangeText={(value) => this.setState({value})}
/>
<Button value="Submit" onPress={this.onSubmit} />
</View>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment