32 lines
755 B
JavaScript
32 lines
755 B
JavaScript
/* eslint-disable react/prop-types */
|
|
|
|
import React, {useState} from 'react'
|
|
|
|
import Checkbox from '@material-ui/core/Checkbox'
|
|
import FormControlLabel from '@material-ui/core/FormControlLabel'
|
|
|
|
|
|
|
|
export default function MCF_Checkbox (props) {
|
|
const [params, setParams] = useState(props.params)
|
|
|
|
const handleChange = event => {
|
|
params.onChangeListener(params.id, event.target.checked)
|
|
setParams({...params, checked: event.target.checked})
|
|
}
|
|
|
|
return (
|
|
<FormControlLabel
|
|
id={params.id} // string
|
|
key={params.id}
|
|
control={
|
|
<Checkbox
|
|
checked={params.checked} // boolean
|
|
onChange={handleChange}
|
|
name={params.id}
|
|
/>
|
|
}
|
|
label={params.label} // string
|
|
/>
|
|
)
|
|
}
|