mirror of
https://github.com/wassname/talk.git
synced 2026-07-15 11:26:58 +08:00
fix: fixed looping effect (#2626)
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user