Skip to content

Remove setStates during render phase on SelectPanel#7498

Merged
hectahertz merged 2 commits intohectahertz/selectpanel-performancefrom
hectahertz/selectpanel-performance-render-phase
Feb 9, 2026
Merged

Remove setStates during render phase on SelectPanel#7498
hectahertz merged 2 commits intohectahertz/selectpanel-performancefrom
hectahertz/selectpanel-performance-render-phase

Conversation

@hectahertz
Copy link
Copy Markdown
Contributor

@hectahertz hectahertz commented Feb 2, 2026

Closes https://github.com/github/primer/issues/5788

The previous code was calling setState directly during render. This is an anti-pattern that causes React to:

  • Start rendering
  • Detect a state update during render
  • Restart the render with the new state
  • Potentially loop multiple times

By converting these to useEffect with refs, the state updates now happen after the render completes, which is more efficient and follows React best practices.

Changelog

Changed

State update logic to remove these issues

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: f240551

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions github-actions bot temporarily deployed to storybook-preview-7498 February 2, 2026 18:32 Inactive
@hectahertz hectahertz changed the title WIP Remove setStates during render on SelectPanel Feb 5, 2026
@hectahertz hectahertz marked this pull request as ready for review February 5, 2026 15:37
@hectahertz hectahertz requested a review from a team as a code owner February 5, 2026 15:37
@hectahertz hectahertz force-pushed the hectahertz/selectpanel-performance-render-phase branch from 67e211e to f240551 Compare February 5, 2026 15:40
@hectahertz hectahertz changed the title Remove setStates during render on SelectPanel Remove setStates during render phase on SelectPanel Feb 5, 2026
@github-actions github-actions bot requested a deployment to storybook-preview-7498 February 5, 2026 15:46 Abandoned
Copy link
Copy Markdown
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

❇️

@primer-integration
Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/13041

@primer-integration
Copy link
Copy Markdown

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@hectahertz hectahertz merged commit 0c19492 into hectahertz/selectpanel-performance Feb 9, 2026
50 checks passed
@hectahertz hectahertz deleted the hectahertz/selectpanel-performance-render-phase branch February 9, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants