Skip to content

Commit

Permalink
fix render loop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nayr974 committed Jan 3, 2025
1 parent df46bea commit 8eff85a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"pure-react-carousel": "^1.30.1",
"react": "^18.2.0",
"react-bootstrap": "^2.7.4",
"react-bootstrap-typeahead": "^6.3.2",
"react-bootstrap-typeahead": "^6.3.4",
"react-chartjs-2": "^5.2.0",
"react-collapsed": "^4.0.2",
"react-collapsible": "^2.10.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useEffect, useState } from "react";
import { FC, useEffect, useState, useCallback } from "react";
import { useAppDispatch, useAppSelector } from "@hooks/hooks";
import { bcUtmZoneNumbers, getSelectedOfficer, formatLatLongCoordinate } from "@common/methods";
import { Coordinates } from "@apptypes/app/coordinate-type";
Expand Down Expand Up @@ -184,9 +184,12 @@ export const ComplaintDetailsEdit: FC = () => {

const [complaintAttachmentCount, setComplaintAttachmentCount] = useState<number>(0);

const handleSlideCountChange = (count: number) => {
setComplaintAttachmentCount(count);
};
const handleSlideCountChange = useCallback(
(count: number) => {
setComplaintAttachmentCount(count);
},
[setComplaintAttachmentCount],
);

//-- use effects
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useEffect, useState } from "react";
import { FC, useCallback, useEffect, useState } from "react";
import { AttachmentsCarousel } from "@components/common/attachments-carousel";
import { COMSObject } from "@apptypes/coms/object";
import { handleAddAttachments, handleDeleteAttachments, handlePersistAttachments } from "@common/attachment-utils";
Expand Down Expand Up @@ -75,9 +75,12 @@ export const OutcomeAttachments: FC<props> = ({ showAddButton = false }) => {
}
}, [carouselData, showAddButton]);

const handleSlideCountChange = (count: number) => {
setOutcomeAttachmentCount(count);
};
const handleSlideCountChange = useCallback(
(count: number) => {
setOutcomeAttachmentCount(count);
},
[setOutcomeAttachmentCount],
);

const saveButtonClick = async () => {
//initial state when there is no attachments
Expand Down

0 comments on commit 8eff85a

Please sign in to comment.