Skip to content

Commit 24e1aa3

Browse files
Merge pull request #2538 from cfpb/2537-crash-with-one-announcement
๐Ÿš€ Currently on Dev: `v3.2.10` ๐Ÿš€ When there's exactly one announcement (since nothing is rendered when there are no announcements), this line preventing the auto-advancement of the announcements is performed inside of a useEffect [in `useAutoAdvance.jsx`](https://github.com/cfpb/hmda-frontend/blob/master/src/common/useAutoAdvance.jsx#L30): if (totalCount < 2) return null Since I believe React 18, you can't return null in a useEffect since it's reserved for a cleanup function, so a useEffect can now only return undefined, nothing, or a cleanup function. Returning null was causing a crash on unmount of the announcement component, throwing an error in the react internals ("t is not a function" when compiled on dev/prod). So when the total number of announcements including timed announcements was equal to one, then the page could crash when the announcement banner unmounted, like on page navigation. This is why crashes only happened when navigating from the home page to another page, and could be "fixed" with a refresh. ## Changes - change `null` to `undefined` in `useAutoAdvance` ## Testing 1. Does the site behave normally? 2. Do the tests pass on Dev? ## Notes In the future I could see a few new e2e tests including one that checks navigation from the home page to the filing app. Closes #2537, #2528
2 parents b6e7dd0 + 356fb04 commit 24e1aa3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

โ€Žsrc/common/useAutoAdvance.jsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const useAutoAdvance = ({
2727
useEffect(() => {
2828
if (isPaused) clearTimeout(advanceTimeout)
2929
else {
30-
if (totalCount < 2) return null
30+
if (totalCount < 2) return undefined
3131
const secs = parseInt(cycleTime)
3232
if (secs > 0) {
3333
advanceTimeout = setTimeout(showNext, secs * 1000)

0 commit comments

Comments
ย (0)