Guest User

Untitled

a guest
Jul 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class InputItem extends React.Component {
  2. state = {
  3. key: "",
  4. value: "",
  5. };
  6.  
  7. onChange(key, value) {
  8. this.setState({
  9. [key]: value
  10. });
  11.  
  12. this.props.onChange({
  13. ...this.state,
  14. [key]: value
  15. }, this.props.index);
  16. };
  17.  
  18. render() {
  19. return (
  20. <View style={{
  21. display: 'flex',
  22. marginBottom: 10,
  23. flexDirection: 'row'
  24. }}>
  25. <TextInput
  26. style={{
  27. height: 40,
  28. borderColor: "gray",
  29. borderWidth: 1,
  30. flex: 1,
  31. marginRight: 5
  32. }}
  33. onChangeText={value => this.onChange('key', value)}
  34. value={this.state.text}
  35. />
  36. <TextInput
  37. style={{
  38. height: 40,
  39. borderColor: "gray",
  40. borderWidth: 1,
  41. flex: 1,
  42. }}
  43. onChangeText={value => this.onChange('value', value)}
  44. value={this.state.text}
  45. />
  46. </View>
  47. );
  48. }
  49. }
Add Comment
Please, Sign In to add comment