i have a homework problem, can i change the value from post.map into value in initial state? because when i want to try edit form, the form wont be change because i use value from post.map and if i use value in initial state the forms is empty if only if you create the form into select and option, but i want to edit by type . how should i do
detailclient.js
this.state = {
post : [],
post2 : [],
post3 : [],
filteredData: [],
urlBlacklist : '',
formData : {
clientId : '',
username : 'admPortal',
clientType : '',
urlBlacklist : '',
name : '',
url : '',
},
isUpdate : false,
isLogedIn,
currentPage: 1,
todosPerPage: 5,
isChecked : false,
modal : false
}
detailclient form
<FormGroup>
<Label htmlFor="url">Url</Label>
<Input onChange={this.handleForm}
value={url}
type="text"
name="url"
className="form-control"
placeholder="Url"
required="" />
</FormGroup>
<FormGroup>
<Label htmlFor="urlBlacklist"> Url Blacklist </Label>
{
(this.state.post3.map((h, i) =>
`${h.clientId}` === `${this.state.urlBlacklist}` &&
<Input
onChange={this.handleForm}
key={i}
value={h.urlBlacklist}
type="text"
name="urlBlacklist"
className="form-control"
placeholder="URL Black List"
required=""
/>
))
}
</FormGroup>
handleform
handleForm = (event) => {
let formDataNew = {...this.state.formData};
formDataNew[event.target.name] = event.target.value;
this.setState ({
formData : formDataNew
})
}
i need to change the value from urlBlacklist into initial state . like value in Url . how to change h.urlBlacklist to initialState but the value in h.urlBlacklist move to initialState? thankyou.