My state looks like this
state = {
basic: {
entry: 'index.js',
output: {
path: 'dist',
filename: 'bundle.js',
}
}
}
I have defined a callback for input onChange event :
handleUpdateString = (e) => {
const name = e.target.name
const value = e.target.value
this.setState({ [name]: value })
console.log(this.state)
}
say my input name is 'basic.entry'
my state is updated, but instead of having this.state.basic be { entry: 'some value'}
I end up with a new key in my state : { basic.entry: 'some value' }
I have tried using dot-object to convert the dot-seperated string to a nested object, and passing this to setState but the state appears to be unchanged.
What are simple solutions to this problem ?
this.setState({ name: value });