Skip to content

Mark useResponsiveValue as deprecated#7760

Merged
siddharthkp merged 3 commits intomainfrom
copilot/mark-useresponsivevalue-deprecated
Apr 16, 2026
Merged

Mark useResponsiveValue as deprecated#7760
siddharthkp merged 3 commits intomainfrom
copilot/mark-useresponsivevalue-deprecated

Conversation

@siddharthkp
Copy link
Copy Markdown
Member

@siddharthkp siddharthkp commented Apr 15, 2026

adr-018-responsive-values.md discourages the use of useResponsiveValue hook because it relies on matchMedia and needs to wait until client hydration to choose the right value.

Authors can use a hook called useResponsiveValue to support resolving the value of a prop based on the current viewport size. The implementation of this hook uses matchMedia which, unfortunately, has a downside: the value of a prop may shift when the component is server-side rendered. If the prop is used for styles or layout, then this will lead to a layout shift when the component hydrates and the viewport size is different than the fallback size on the server.

But, we still export this hook without any warnings. This came up in a conversation on slack.

Marking the hook as deprecated in the docs because we want people to use css media queries instead.

Bonus:

  • Add a reusable .github/skills/deprecations/SKILL.md guide for deprecating components and hooks.
  • Update contributor-docs/deprecating-components.md to document how deprecated status should be represented in component and hook docs metadata.

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

Merge checklist

Copilot AI and others added 2 commits April 15, 2026 12:59
Agent-Logs-Url: https://github.com/primer/react/sessions/b0c0f40d-21cd-449f-8c67-2bd64b08b8b3

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Agent-Logs-Url: https://github.com/primer/react/sessions/6f8c4762-fc70-4d71-ba62-cdade4e3de3a

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: d82618b

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 Minor

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 staff Author is a staff member label Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 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. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label 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 Apr 15, 2026
@siddharthkp siddharthkp marked this pull request as ready for review April 15, 2026 14:25
@siddharthkp siddharthkp requested a review from a team as a code owner April 15, 2026 14:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Marks the useResponsiveValue hook as deprecated in Primer React documentation and metadata tooling, aligning with ADR-018 guidance to avoid SSR hydration layout shifts.

Changes:

  • Add a JSDoc @deprecated annotation to useResponsiveValue with guidance to use getResponsiveAttributes + CSS media queries.
  • Introduce "status": "deprecated" for hooks in *.hookDocs.json, including schema/tooling support.
  • Add/extend contributor guidance for deprecations (new skill doc + update existing deprecation docs) and include a minor changeset.
Show a summary per file
File Description
packages/react/src/hooks/useResponsiveValue.ts Adds @deprecated JSDoc annotation to the hook.
packages/react/src/hooks/useResponsiveValue.hookDocs.json Marks hook docs metadata as deprecated via "status": "deprecated".
packages/react/script/hooks-json/hook.schema.json Adds status field to the hook docs JSON schema.
packages/react/script/hooks-json/build.ts Updates the local Hook type to include optional deprecated status.
contributor-docs/deprecating-components.md Documents representing deprecated status in docs metadata for components/hooks.
.github/skills/deprecations/SKILL.md Adds a reusable deprecations checklist/guide.
.changeset/cold-lions-listen.md Adds a minor changeset announcing the deprecation.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 0

@github-actions github-actions bot temporarily deployed to storybook-preview-7760 April 15, 2026 14:33 Inactive
@siddharthkp siddharthkp added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Apr 15, 2026
- [ ] Adding a `@deprecated` annotation in the component's source code.
- [ ] Adding a `Deprecation` section to the documentation of the component with the link of the recommended component and provide a diff. See [deprecated ActionList docs](https://primer.style/react/deprecated/ActionList#deprecation) as an example.
- [ ] Marking the component or hook docs metadata as deprecated with `"status": "deprecated"` in the relevant `*.docs.json` or `*.hookDocs.json` file.
- [ ] If the component has a docs page, adding a `Deprecation` section to the documentation with the link of the recommended component and provide a diff. See [deprecated ActionList docs](https://primer.style/react/deprecated/ActionList#deprecation) as an example.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this link does not exist?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

My bad, that link was already there. Replaced with a link for a recent deprecated component

Comment on lines +81 to +85
"status": {
"type": "string",
"enum": ["deprecated"],
"description": "The status of the hook."
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

only valid value is deprecated? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes... because there was no status field so far.

Made it ["ready", "deprecated"] so it doesn't look weird

@primer-integration
Copy link
Copy Markdown

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

@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!

@siddharthkp siddharthkp added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit b2e0efd Apr 16, 2026
53 checks passed
@siddharthkp siddharthkp deleted the copilot/mark-useresponsivevalue-deprecated branch April 16, 2026 08:18
@primer primer bot mentioned this pull request Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants