fix: fixed looping effect (#2626)

This commit is contained in:
Wyatt Johnson
2019-10-04 19:53:14 +00:00
committed by GitHub
parent 191687335b
commit e7ab0b27f9
@@ -37,18 +37,19 @@ const Moderate: FunctionComponent<Props> = ({
const closeModal = useCallback(() => {
setShowHotkeysModal(false);
}, []);
const toggleModal = useCallback(() => {
setShowHotkeysModal(!showHotkeysModal);
}, [showHotkeysModal]);
useEffect(() => {
const toggleModal = () => {
setShowHotkeysModal(was => !was);
};
// Attach the modal toggle when the GUIDE button is pressed.
key(HOTKEYS.GUIDE, toggleModal);
return () => {
// Detach the modal toggle if we have to rebind it.
key.unbind(HOTKEYS.GUIDE);
};
}, [toggleModal]);
}, []);
return (
<div data-testid="moderate-container">