We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f424a81 commit d5b7133Copy full SHA for d5b7133
README.md
@@ -369,6 +369,32 @@ class App extends React.Component<{}, { // no props
369
}
370
```
371
372
+You can also use React's event handler types like this:
373
+
374
+```tsx
375
+class App extends React.Component<{}, { // no props
376
+ text: string,
377
+ }> {
378
+ state = {
379
+ text: ''
380
+ }
381
+ render() {
382
+ return (
383
+ <div>
384
+ <input
385
+ type="text"
386
+ value={this.state.text}
387
+ onChange={this.onChange}
388
+ />
389
+ </div>
390
+ );
391
392
+ onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
393
+ this.setState({text: e.currentTarget.value})
394
395
+}
396
+```
397
398
[Something to add? File an issue](https://github.com/sw-yx/react-typescript-cheatsheet/issues/new).
399
400
# Section 3: Advanced Guides
0 commit comments