File tree Expand file tree Collapse file tree 2 files changed +49
-49
lines changed
docs/src/examples/modules/Checkbox Expand file tree Collapse file tree 2 files changed +49
-49
lines changed Original file line number Diff line number Diff line change 1- import React , { Component } from 'react'
1+ import React from 'react'
22import { Form , Checkbox } from 'semantic-ui-react'
33
4- export default class CheckboxExampleRadioGroup extends Component {
5- state = { }
6- handleChange = ( e , { value } ) => this . setState ( { value } )
4+ function CheckboxExampleRadioGroup ( ) {
5+ const [ value , setValue ] = React . useState ( 'this' )
76
8- render ( ) {
9- return (
10- < Form >
11- < Form . Field >
12- Selected value: < b > { this . state . value } </ b >
13- </ Form . Field >
14- < Form . Field >
15- < Checkbox
16- radio
17- label = 'Choose this'
18- name = 'checkboxRadioGroup'
19- value = 'this'
20- checked = { this . state . value === 'this' }
21- onChange = { this . handleChange }
22- />
23- </ Form . Field >
24- < Form . Field >
25- < Checkbox
26- radio
27- label = 'Or that'
28- name = 'checkboxRadioGroup'
29- value = 'that'
30- checked = { this . state . value === 'that' }
31- onChange = { this . handleChange }
32- />
33- </ Form . Field >
34- </ Form >
35- )
36- }
7+ return (
8+ < Form >
9+ < Form . Field >
10+ Selected value: < b > { value } </ b >
11+ </ Form . Field >
12+ < Form . Field >
13+ < Checkbox
14+ radio
15+ label = 'Choose this'
16+ name = 'checkboxRadioGroup'
17+ value = 'this'
18+ checked = { value === 'this' }
19+ onChange = { ( e , data ) => setValue ( data . value ) }
20+ />
21+ </ Form . Field >
22+ < Form . Field >
23+ < Checkbox
24+ radio
25+ label = 'Or that'
26+ name = 'checkboxRadioGroup'
27+ value = 'that'
28+ checked = { value === 'that' }
29+ onChange = { ( e , data ) => setValue ( data . value ) }
30+ />
31+ </ Form . Field >
32+ </ Form >
33+ )
3734}
35+
36+ export default CheckboxExampleRadioGroup
Original file line number Diff line number Diff line change 1- import React , { Component } from 'react'
1+ import React from 'react'
22import { Button , Checkbox } from 'semantic-ui-react'
33
4- export default class CheckboxExampleRemoteControl extends Component {
5- state = { checked : false }
6- toggle = ( ) => this . setState ( ( prevState ) => ( { checked : ! prevState . checked } ) )
4+ function CheckboxExampleRemoteControl ( ) {
5+ const [ checked , setChecked ] = React . useState ( false )
76
8- render ( ) {
9- return (
10- < div >
11- < Button onClick = { this . toggle } > Toggle it</ Button >
12- < Checkbox
13- label = 'Check this box'
14- onChange = { this . toggle }
15- checked = { this . state . checked }
16- />
17- </ div >
18- )
19- }
7+ return (
8+ < div >
9+ < Button onClick = { ( ) => setChecked ( ( prevChecked ) => ! prevChecked ) } >
10+ Toggle it
11+ </ Button >
12+ < Checkbox
13+ label = 'Check this box'
14+ onChange = { ( e , data ) => setChecked ( data . checked ) }
15+ checked = { checked }
16+ / >
17+ </ div >
18+ )
2019}
20+
21+ export default CheckboxExampleRemoteControl
You can’t perform that action at this time.
0 commit comments