Skip to content

Commit bafa1bc

Browse files
committed
combine the useEffects in FetchMoreGalleriesData
1 parent cc865b5 commit bafa1bc

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

dotcom-rendering/src/components/FetchMoreGalleriesData.importable.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ export const FetchMoreGalleriesData = ({
101101
.then((fetchedData) => {
102102
setData(fetchedData);
103103
setError(undefined);
104+
addDiscussionIds(
105+
fetchedData.trails
106+
.map((trail) => trail.discussion?.discussionId)
107+
.filter(isNonNullable),
108+
);
104109
})
105110
.catch((err) => {
106111
setError(
@@ -110,15 +115,6 @@ export const FetchMoreGalleriesData = ({
110115
});
111116
}, [ajaxUrl]);
112117

113-
useEffect(() => {
114-
if (!data) return;
115-
addDiscussionIds(
116-
data.trails
117-
.map((trail) => trail.discussion?.discussionId)
118-
.filter(isNonNullable),
119-
);
120-
}, [data]);
121-
122118
if (error) {
123119
// Send the error to Sentry and then prevent the element from rendering
124120
window.guardian.modules.sentry.reportError(error, 'more-galleries');

0 commit comments

Comments
 (0)