Skip to content

refactor: render view-builder components as jsx elements instead of plain function calls (rules-of-hooks) (#4877)#4884

Merged
NoopDog merged 2 commits into
mainfrom
fran/4877-render-view-builder-components-as-jsx
Jul 1, 2026
Merged

refactor: render view-builder components as jsx elements instead of plain function calls (rules-of-hooks) (#4877)#4884
NoopDog merged 2 commits into
mainfrom
fran/4877-render-view-builder-components-as-jsx

Conversation

@frano-m

@frano-m frano-m commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #4877.

Converts every view-model builder call of the form C.Component({...}) (calling a component as a plain function) into <C.Component {...} /> (rendering it as a JSX element). Calling a hook-using component as a plain function executes its hooks inside whatever renders the builder output (findable-ui's ComponentCreator) rather than in the component's own scope — a Rules of Hooks violation. The confirmed hook-using case is C.BackPageHeroActions (useConfiguseContext); the rest are hookless presentational builders converted uniformly so the foot-gun can't be silently reintroduced.

JSX requires .tsx, so the affected builder files were renamed via git mv (history preserved).

Changes

  • 37 call sites converted across 4 files:
    File Sites
    app/viewModelBuilders/azul/hca-dcp/common/viewModelBuilders.tsx 20
    app/viewModelBuilders/catalog/anvil-catalog/common/viewModelBuilders.tsx 15
    app/viewModelBuilders/azul/hca-dcp/common/dataSummaryMapper/dataSummaryMapper.tsx 1
    app/viewModelBuilders/azul/lungmap/common/viewModelBuilders.tsx 1
  • Added key props to the elements in C.ButtonGroup's Buttons array (required once they are JSX elements in an array literal).
  • Named the returned component in getAnalysisPortalsKeyValueElType to satisfy react/display-name (it returns a component directly rather than assigning it to a prop).

Direct non-C. builder calls (e.g. NTagCell({...}) imported directly) were intentionally left as-is — they're outside the issue's scope.

Verification

  • Affected .ts builder files renamed to .tsx via git mv
  • C.Component({...}) invocations rendered as <C.Component {...} /> (all 37)
  • next build --webpack green — hca-dcp, anvil-catalog, lungmap configs
  • npm run lint (0 errors), npx tsc (clean), npx prettier --check (clean) on changed files
  • Unit tests green (129 passed)
  • e2e green — anvil-catalog suite (chromium): 16 passed, 3 skipped, 0 failed

🤖 Generated with Claude Code

@frano-m frano-m marked this pull request as ready for review July 1, 2026 03:44
@frano-m frano-m requested a review from Copilot July 1, 2026 03:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes a React Rules-of-Hooks foot-gun in view-model builders by replacing C.Component({ ... }) plain function invocations with proper JSX element rendering (<C.Component ... />) across the affected builder modules, and renames those modules to .tsx to support JSX.

Changes:

  • Converted 37 C.Component({ ... }) builder call sites to JSX elements to ensure any hook-using builders execute hooks in their own component scope.
  • Updated builder-returned element types/props patterns (including Buttons arrays) to be valid JSX (e.g., adding key props where elements are in an array literal).
  • Adjusted a returned component to be named to satisfy react/display-name when returning a component type directly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
app/viewModelBuilders/catalog/anvil-catalog/common/viewModelBuilders.tsx Converts multiple builder component calls to JSX for consistent, hook-safe rendering in AnVIL catalog views.
app/viewModelBuilders/azul/lungmap/common/viewModelBuilders.tsx Updates a FileNameCell builder call to JSX in the LungMAP builder.
app/viewModelBuilders/azul/hca-dcp/common/viewModelBuilders.tsx Bulk conversion of builder calls to JSX, including hook-using BackPageHeroActions, plus JSX array keying and display-name adjustment.
app/viewModelBuilders/azul/hca-dcp/common/dataSummaryMapper/dataSummaryMapper.tsx Converts a TypographyWordBreak builder call to JSX in the data summary mapper.
Comments suppressed due to low confidence (1)

app/viewModelBuilders/azul/hca-dcp/common/viewModelBuilders.tsx:710

  • Typo in the eslint-disable rationale comment: NOOPRNER should be NOOPENER (refers to the noopener part of rel="noopener noreferrer").

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

frano-m and others added 2 commits July 1, 2026 14:58
…lain function calls (rules-of-hooks) (#4877)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…4877)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@frano-m frano-m force-pushed the fran/4877-render-view-builder-components-as-jsx branch from d1c80e7 to 7f18a63 Compare July 1, 2026 04:58
@NoopDog NoopDog merged commit 7c33510 into main Jul 1, 2026
3 checks passed
@frano-m frano-m deleted the fran/4877-render-view-builder-components-as-jsx branch July 1, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: render view-builder components as JSX elements instead of plain function calls (rules-of-hooks) [low priority]

3 participants