Well I have an event that happens "onchange" from a text input.
One of the obvious fields I would like to get during event handling is the new value of the input. A simple example is shown below:
onChange = (event: SyntheticInputEvent<>) => {
const target = event.currentTarget;
const {something} = this.props;
if (target && target.hasOwnProperty('value')) {
something[fieldname] = target.value;
}
};
This however chokes flow: flow complains that about:
Error:(34, 47) Cannot get
target.value
because propertyvalue
is missing inEventTarget
[1].
Now how can I correctly refine this type? Apparently flow doesn't understand hasOwnProperty
. Is there a better way?
The
SyntheticInputEvent
generic requires type argument, you seems to missed it.Smth, like this should make flow happy: