fix useEffect loop

This commit is contained in:
Tom
2023-05-19 07:01:27 +02:00
parent 03f8f751bb
commit a7b1ad2fee
2 changed files with 20 additions and 4 deletions
+10 -2
View File
@@ -70,6 +70,7 @@ const Board = () => {
const [prevScrollPos, setPrevScrollPos] = useState(0);
const [visible, setVisible] = useState(true);
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
const [selectedFeed, setSelectedFeed] = useState(feed);
const [rotatedStates, setRotatedStates] = useState({});
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
@@ -402,6 +403,8 @@ const Board = () => {
default:
break;
}
setTriggerPublishCommentEdit(true);
};
@@ -414,8 +417,13 @@ const Board = () => {
useEffect(() => {
publishCommentEdit();
}, [publishCommentEditOptions, publishCommentEdit]);
if (publishCommentEditOptions && triggerPublishCommentEdit) {
(async () => {
await publishCommentEdit();
setTriggerPublishCommentEdit(false);
})();
}
}, [publishCommentEditOptions, triggerPublishCommentEdit, publishCommentEdit]);
// desktop navbar board select functionality
+10 -2
View File
@@ -60,6 +60,7 @@ const Thread = () => {
const replyMenuRefs = useRef({});
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
const [errorMessage, setErrorMessage] = useState(null);
const [successMessage, setSuccessMessage] = useState(null);
const [isReplyOpen, setIsReplyOpen] = useState(false);
@@ -375,6 +376,8 @@ const Thread = () => {
default:
break;
}
setTriggerPublishCommentEdit(true);
};
@@ -387,8 +390,13 @@ const Thread = () => {
useEffect(() => {
publishCommentEdit();
}, [publishCommentEditOptions, publishCommentEdit]);
if (publishCommentEditOptions && triggerPublishCommentEdit) {
(async () => {
await publishCommentEdit();
setTriggerPublishCommentEdit(false);
})();
}
}, [publishCommentEditOptions, triggerPublishCommentEdit, publishCommentEdit]);
// mobile navbar board select functionality
const handleSelectChange = (event) => {