React: add typed target for change events

This commit is contained in:
Patricio Zavolinsky
2017-01-14 15:21:58 +00:00
committed by Patricio Zavolinsky
parent d26ba1fb9c
commit cfe2a21973
2 changed files with 30 additions and 7 deletions

View File

@@ -672,3 +672,19 @@ class ConstructorSpreadArgsPureComponent extends React.PureComponent<{}, {}> {
super(...args);
}
}
//
// The SyntheticEvent.target.value should be accessible for onChange
// --------------------------------------------------------------------------
class SyntheticEventTargetValue extends React.Component<{}, { value: string }> {
constructor(props:{}) {
super(props);
this.state = { value: 'a' };
}
render() {
return React.DOM.textarea({
value: this.state.value,
onChange: e => this.setState({value: e.target.value})
});
}
}