File tree Expand file tree Collapse file tree 1 file changed +41
-35
lines changed Expand file tree Collapse file tree 1 file changed +41
-35
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for */
1
2
import * as React from 'react' ;
2
3
import List from '../src/List' ;
3
4
@@ -35,50 +36,55 @@ function getData(count: number) {
35
36
36
37
const Demo = ( ) => {
37
38
const [ height , setHeight ] = React . useState ( 200 ) ;
38
- const [ state , setState ] = React . useState < number > ( 1 ) ;
39
-
40
- const data = React . useMemo ( ( ) => {
41
- switch ( state ) {
42
- case 0 :
43
- return getData ( 1000 ) ;
44
- case 1 :
45
- return getData ( 2 ) ;
46
- default :
47
- return getData ( 0 ) ;
48
- }
49
- } , [ state ] ) ;
39
+ const [ data , setData ] = React . useState ( getData ( 2 ) ) ;
50
40
51
41
return (
52
42
< React . StrictMode >
53
43
< div >
54
44
< h2 > Switch</ h2 >
55
-
56
- < button
57
- type = "button"
58
- onClick = { ( ) => {
59
- setState ( ( state + 1 ) % 3 ) ;
45
+ < span
46
+ onChange = { ( e : any ) => {
47
+ setData ( getData ( Number ( e . target . value ) ) ) ;
60
48
} }
61
49
>
62
- Switch
63
- </ button >
64
- < button
65
- type = "button"
66
- onClick = { ( ) => {
67
- switch ( height ) {
68
- case 200 :
69
- setHeight ( 0 ) ;
70
- break ;
71
- case 0 :
72
- setHeight ( 100 ) ;
73
- break ;
74
- default :
75
- setHeight ( 200 ) ;
76
- break ;
77
- }
50
+ Data
51
+ < label >
52
+ < input type = "radio" name = "switch" value = { 0 } /> 0
53
+ </ label >
54
+ < label >
55
+ < input type = "radio" name = "switch" value = { 2 } /> 2
56
+ </ label >
57
+ < label >
58
+ < input type = "radio" name = "switch" value = { 100 } />
59
+ 100
60
+ </ label >
61
+ < label >
62
+ < input type = "radio" name = "switch" value = { 200 } />
63
+ 200
64
+ </ label >
65
+ < label >
66
+ < input type = "radio" name = "switch" value = { 1000 } />
67
+ 1000
68
+ </ label >
69
+ </ span >
70
+ < span
71
+ onChange = { ( e : any ) => {
72
+ setHeight ( Number ( e . target . value ) ) ;
78
73
} }
79
74
>
80
- Height
81
- </ button >
75
+ | Height
76
+ < label >
77
+ < input type = "radio" name = "switch" value = { 0 } /> 0
78
+ </ label >
79
+ < label >
80
+ < input type = "radio" name = "switch" value = { 100 } />
81
+ 100
82
+ </ label >
83
+ < label >
84
+ < input type = "radio" name = "switch" value = { 200 } />
85
+ 200
86
+ </ label >
87
+ </ span >
82
88
83
89
< List
84
90
data = { data }
You can’t perform that action at this time.
0 commit comments