import React from 'react'; import { Checkbox } from '@patternfly/react-core'; export const CheckboxControlled: React.FunctionComponent = () => { const [isChecked1, setIsChecked1] = React.useState(false); const [isChecked2, setIsChecked2] = React.useState(false); const [isChecked3, setIsChecked3] = React.useState(false); const [isChecked4, setIsChecked4] = React.useState(false); const handleChange = (event: React.FormEvent, checked: boolean) => { const target = event.currentTarget; const name = target.name; switch (name) { case 'check1': setIsChecked1(checked); break; case 'check2': setIsChecked2(checked); break; case 'check3': setIsChecked3(checked); break; case 'check4': setIsChecked4(checked); break; default: // eslint-disable-next-line no-console console.log(name); } }; React.useEffect(() => { if (isChecked1 !== null) { setIsChecked2(isChecked1); setIsChecked3(isChecked1); } }, [isChecked1]); React.useEffect(() => { setIsChecked1((isChecked2 && isChecked3) || (isChecked2 || isChecked3 ? null : false)); }, [isChecked2, isChecked3]); return ( } /> ); };