Skip to content

Commit

Permalink
refact: rewrite some effect-state updates as functional updates
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Aug 21, 2024
1 parent 01507ef commit c641f31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/manager/drs/ManagerDRSContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ const ManagerDRSContent = () => {
}, [performSearch, searchValue]);

useEffect(() => {
setSelectedRowKeys(selectedRowKeys.filter((k) => k in objectsByID));
}, [selectedRowKeys, objectsByID]);
setSelectedRowKeys((s) => s.filter((k) => k in objectsByID));
}, [objectsByID]);

const onDeleteSelected = useCallback(() => {
Modal.confirm({
Expand Down
8 changes: 4 additions & 4 deletions src/components/manager/projects/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ const Project = ({

useEffect(() => {
if (value) {
setProjectState({
...projectState,
setProjectState((ps) => ({
...ps,
...value,
data_use: simpleDeepCopy(value.data_use || INITIAL_DATA_USE_VALUE),
});
}));
}
}, [value, projectState]);
}, [value]);

const handleSave = useCallback(() => {
const form = editingForm.current;
Expand Down

0 comments on commit c641f31

Please sign in to comment.