fix: correct frontend effect dependency arrays - #1709
Draft
shivoomiess wants to merge 1 commit into
Draft
Conversation
shivoomiess
force-pushed
the
fix/frontend-effect-dependencies
branch
from
August 6, 2026 08:47
5730ab7 to
1d10bde
Compare
shivoomiess
force-pushed
the
fix/frontend-effect-dependencies
branch
from
August 6, 2026 09:20
1d10bde to
7b49d42
Compare
shivoomiess
force-pushed
the
fix/frontend-effect-dependencies
branch
from
August 6, 2026 11:41
7b49d42 to
49be444
Compare
`react-hooks/exhaustive-deps` reported 18 warnings. 13 of them are independent of the table stack and are fixed here; the other 5 are left for the material-table migration to absorb (see below). Every missing dependency in the seven data hooks is a query parameter that the effect reads but never re-runs for, so the hook returns data for whatever argument it happened to receive first: - `useEventsData`, `useStatusesData`, `useWorkflowsData` - `entityType` - `useFapProposalsData` - `legacy` - `useVisitRegistration` - `userId` - `useUserExperiments` - `notDraft`, `onlyUpcoming`, `instrumentId` - `useStatusActionsData` - `isPregeneratedProposalPdfsEnabled` None of these can loop. `api` comes from `useDataApi`, which returns a `useCallback`, and every added dependency is a primitive - a string enum, a number, or a boolean. The `useStatusActionsData` one is a real bug rather than a latent risk. The flag comes from `FeatureContext` and decides whether `PROPOSALDOWNLOAD` is filtered out of the result. Because it was not a dependency, the filter used whatever the flag was when the effect first ran; if the feature context resolved after that first fetch, the action list was wrong until something else forced a refetch. The rest are structural, with no behaviour change: - `ChangeProposalStatus` passed `selectedProposalsWorkflowIds[0]` directly in the array, which the rule cannot statically verify. Extracted to `primaryWorkflowId` and used in both places. - `ShipmentContainer` referenced `props.onDirtyStateChange`, so the rule wanted the whole `props` object - which changes every render. Destructured the callback instead; the dependency value is identical, just checkable. - `ReviewSummary` and `TechnicalReviewSummary` depended on `api` while their effects had stopped calling it, and were missing `<review>.proposal?.callId`, which the rule cannot track through an optional chain. Extracted to `callId` and dropped the dead `api` dependency. - `QuestionaryComponentInstrumentPicker` needed `getValueWithInstrumentName`, which was rebuilt on every render. Wrapped in `useCallback` keyed on `value` and `config`. Both are read off `answer`, which the effect already depends on, so the effect cannot run more often than it does today - if `answer` were unstable this component would already be looping, because it already calls `setRequestTimeForInstrument` on every run. Deferred - all 5 sit on @material-table/core internals and will be rewritten or deleted by the v8 migration, so fixing them now would only create conflicts: `useExpandCollapseAll` (reaches into `dataManager.sortedData`, `props.detailPanel` and scrapes `thead tr` from the DOM), `ProposalTableInstrumentScientist` (drives `tableData.checked`) and `FapInstrumentProposalsTable`. `tsc --noEmit`, `eslint` and `vite build` pass. Not exercised at runtime.
shivoomiess
force-pushed
the
fix/frontend-effect-dependencies
branch
from
August 10, 2026 12:22
49be444 to
5a61e8f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR corrects the effect dependency arrays in several frontend components to ensure the correct functioning and optimized rendering of components.
Motivation and Context
These changes are required to maintain the correct functionality and prevent unnecessary re-rendering of components in the frontend, which may lead to improved performance and prevent potential bugs.
Changes
useEffecthooks to ensure that the correct dependencies are tracked.useEffectdependencies with the newly introduced local variables.useEffectinQuestionaryComponentInstrumentPickerwithuseCallbackto create a memoized version of the function, preventing unnecessary re-rendering.Note: These changes have been made across multiple files including
ChangeProposalStatus.tsx,QuestionaryComponentInstrumentPicker.tsx,ReviewSummary.tsx,TechnicalReviewSummary.tsx,ShipmentContainer.tsxand several others.How Has This Been Tested?
Fixes Jira Issue
https://jira.ess.eu//browse/
Depends On
Tests included/Docs Updated?