Skip to content

Commit

Permalink
minorly prevent rerenders
Browse files Browse the repository at this point in the history
  • Loading branch information
Jemoka committed Sep 10, 2024
1 parent 783af05 commit bc35d85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/datemodal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export default forwardRef(function DateModal({ onDate, initialDate, onClose }, r
}

useOutsideAlerter(wrapperRef, () => {
if (typeof onClose == "function") {
onClose();
if (!open) {
if (typeof onClose == "function") {
onClose();
}
setOpen(false);
}
setOpen(false);
});

return (
Expand Down
6 changes: 5 additions & 1 deletion src/components/task.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export default function Task( { task, initialFocus, onFocusChange } ) {

const wrapperRef = useRef(null);
const cm = useRef(null);
useOutsideAlerter(wrapperRef, () => setHasFocus(false));
useOutsideAlerter(wrapperRef, () => {
if (!hasFocus) {
setHasFocus(false);
}
});

useEffect(() => {
if (typeof onFocusChange == "function") onFocusChange(hasFocus);
Expand Down

0 comments on commit bc35d85

Please sign in to comment.