简体   繁体   中英

How can bind the "areaName" on <TexBox> vlaue=" " and onChange=" ":?

Actually, I have called an API and map the array and bind the data on <TableCell>

 {this.state.allArea.map((allArea, i) => (
                    <TableRow >
                        <TableCell >{allArea.areaName}</TableCell>
                <TableCell  >{allArea.cityName}</TableCell>
                        <TableCell > <IconButton aria-label="edit" onClick= 
                  {this.addCoupon.bind(this)}  >
                                   <EditIcon />
                     </IconButton><IconButton aria-label="delete">
                        <DeleteIcon />
                       </IconButton></TableCell> </TableRow>
                 ))}

But Now, I want to edit/update the areaName so I create a <TexBox>

       <Grid container spacing={8}>
                <Grid item md={12} sm={12} xs={12} >
                    <TextBox error='' value='' name="name" label="Area name" required={true} onChange={this.handleAreaChange.bind(this)} ></TextBox>
                </Grid>

            </Grid>

but I am unable to bind areaName at value="" and onChange=''

Define like this

  <TextBox error='' value={areaName} 
   name="name" label="Area name" 
   required={true} onChange={this.handleAreaChange} >
  </TextBox>

handleAreaChange function

  handleAreaChange=e=>{
   this.setState({areaName:e.target.value})
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM