const textWidth =
($node.current.textLength && $node.current.textLength.baseVal.value) || 0;
useEffect(() => {
setIsDisabled(props.disabled);
if (isDisabled) {
switchEl.current.removeEventListener('click', handleClick);
} else {
switchEl.current.addEventListener('click', handleClick);
}
return () => switchEl.current.addEventListener('click', handleClick);
}, [props.disabled])
const handleClick = event => {
if (isDisabled) return false;
...
}
useEffect(() => {
setIsDisabled(props.disabled);
return () => switchEl.current.removeEventListener('click', handleClick);
}, [props.disabled])
на такие собеседования можно вообще не ходить