Commit 24e1aa3
authored
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, #25281 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
0 commit comments