Created custom Form
component which supposed to change its data
when child inputs change.
Long story short:
In the current context currentTarget
is the form, target
is the input which triggered the event. target
is exactly what I need - since I can then update the data:
this.setState({
data: {
[e.target.name]: e.target.value
}
});
Any ideas?
- Wrong event type?
- Any way to cast in TypeScript (already tried)?
- Wrong approach?
EDIT: something like this works, but this is just wrong:
handleChange(e: React.FormEvent) { let foo: any = e; this.setState({ data: { [foo.target.name]: foo.target.value } }); }