1
- import React , { useEffect , useState } from 'react'
1
+ import React from 'react'
2
2
import PropTypes from 'prop-types'
3
3
import classNames from 'classnames'
4
4
5
5
//component - CoreUI / CSwitch
6
-
7
6
const CSwitch = props => {
8
7
9
8
let {
@@ -16,19 +15,9 @@ const CSwitch = props => {
16
15
labelOff,
17
16
variant,
18
17
shape,
19
- checked,
20
- onCheckedChange,
21
18
...attributes
22
19
} = props
23
20
24
- const [ isChecked , setIsChecked ] = useState ( checked )
25
- useEffect ( ( ) => setIsChecked ( checked ) , [ checked ] )
26
-
27
- const change = e => {
28
- setIsChecked ( e . target . checked )
29
- onCheckedChange && onCheckedChange ( e . target . checked )
30
- }
31
-
32
21
//render
33
22
const classes = classNames (
34
23
'c-switch form-check-label' ,
@@ -49,14 +38,13 @@ const CSwitch = props => {
49
38
< input
50
39
className = { inputClasses }
51
40
type = "checkbox"
52
- onChange = { change }
53
- checked = { ! ! isChecked }
54
41
{ ...attributes }
55
42
ref = { innerRef }
56
43
/>
57
- < span className = "c-switch-slider"
58
- data-checked = { labelOn }
59
- data-unchecked = { labelOff }
44
+ < span
45
+ className = "c-switch-slider"
46
+ data-checked = { labelOn }
47
+ data-unchecked = { labelOff }
60
48
/>
61
49
</ label >
62
50
)
@@ -70,10 +58,8 @@ CSwitch.propTypes = {
70
58
shape : PropTypes . oneOf ( [ '' , 'pill' , 'square' ] ) ,
71
59
variant : PropTypes . oneOf ( [ '' , '3d' , 'opposite' , 'outline' ] ) ,
72
60
color : PropTypes . string ,
73
- checked : PropTypes . bool ,
74
61
labelOn : PropTypes . string ,
75
62
labelOff : PropTypes . string ,
76
- onCheckedChange : PropTypes . func
77
- } ;
63
+ }
78
64
79
65
export default CSwitch
0 commit comments