File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,32 @@ class App extends React.Component<{}, { // no props
369
369
}
370
370
```
371
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
+
372
398
[ Something to add? File an issue] ( https://github.com/sw-yx/react-typescript-cheatsheet/issues/new ) .
373
399
374
400
# Section 3: Advanced Guides
You can’t perform that action at this time.
0 commit comments