Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import TextField from '@material-ui/core/TextField';
  3. import Button from '@material-ui/core/Button';
  4.  
  5.  
  6.  
  7. class AddRow extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state ={
  11. addRow: {}
  12. }
  13. }
  14. handleChange = (event) => {
  15. const {value, name} = event.target;
  16. this.setState({
  17. addRow: [name] : value
  18. })
  19. }
  20.  
  21. render(){
  22. const {columns} = this.props;
  23.  
  24. return(
  25. <div>
  26. {columns.map((column) => <TextField key={column.id}
  27. label={column.name}
  28. name={column.prop}
  29. onChange={event => this.handleChange(event)}/>)}
  30. <Button variant="contained" color="primary" onClick={() => console.log(this.state.addRow)}>
  31. Добавить
  32. </Button>
  33. </div>
  34.  
  35. );
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement