Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HMR errors #5209

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Fix HMR errors #5209

wants to merge 2 commits into from

Conversation

dusave
Copy link
Contributor

@dusave dusave commented Nov 1, 2024

Closes #

Changelog

New

Changed

Removed

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

@dusave dusave self-assigned this Nov 1, 2024
Copy link
Contributor

github-actions bot commented Nov 1, 2024

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@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 Nov 1, 2024
@github-actions github-actions bot temporarily deployed to storybook-preview-5209 November 1, 2024 16:40 Inactive
Copy link
Contributor

github-actions bot commented Nov 1, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 98.54 KB (+0.06% 🔺)
packages/react/dist/browser.umd.js 98.96 KB (+0.09% 🔺)

Copy link

changeset-bot bot commented Nov 1, 2024

🦋 Changeset detected

Latest commit: db2f82e

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

if (anchorRef.current) {
// Necessary for HMR reloads
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (anchorRef?.current) {
Copy link
Member

@joshblack joshblack Nov 4, 2024

Choose a reason for hiding this comment

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

Just curious, do we know why this ref is undefined when doing our upstream work in dotcom? 🤔 Specifically for HMR. It seems like something is happening with the context value being passed along that's different from how it's being represented in TS?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We think it's because the DOM is being replaced, but honestly that's just a theory 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like @camertron said, we think the DOM is being rebuilt and inserted, which temporarily seems to make the refs undefined. However, it's barely undefined long enough to matter. By the time the page renders, everything is rehydrated and all works fine. But for that split second while it's being swapped out, React throws a fit.

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.

3 participants