I have the following snippet of code:
onChange(e) {
e.persist
this.setState((prevState) => {
prevState[e.target.id] = e.target.value
return prevState
})
}
the how would i set the state for each key using something like the code above.
this is the initial state:
this.state = {
heading: this.props.match.params.length > 1 ? "Edit Post" : "Create Post",
title: '',
category: '',
body: '',
author: ''
}