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: regression in #6813 #6827

Merged
merged 1 commit into from
May 31, 2024
Merged

fix: regression in #6813 #6827

merged 1 commit into from
May 31, 2024

Conversation

stipsan
Copy link
Member

@stipsan stipsan commented May 31, 2024

The change in #6813 caused some regressions.

For example previously this would log HTMLDivElement on the first render:

function MyComponent() {
  const ref = React.useRef(null)
  React.useEffect(() => {
    console.log(ref?.current)
  }, [])

  return <Pane ref={ref} />
}

But in #6813 it's null, forcing you to use this pattern for it to be safe:

function MyComponent() {
  const [el, setEl] = React.useState(null)
  React.useEffect(() => {
    console.log(el) // eventually logs `HTMLDivElement`
  }, [el])

  return <Pane ref={setEl} />
}

In this PR we regain the behaviour that it's HTMLDivElement on the first render, while preserving the ability for React Compiler to compile <Pane /> since it still uses useImperativeHandle instead of useForwardedRef 🙌

It also preserves the behaviour that rootElement has a value on the first render of useEffect hooks inside Pane.

@stipsan stipsan requested a review from a team as a code owner May 31, 2024 10:50
@stipsan stipsan requested review from bjoerge and removed request for a team May 31, 2024 10:50
Copy link

vercel bot commented May 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 10:51am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 10:51am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 10:51am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 10:51am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 10:51am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) May 31, 2024 10:51am

Copy link
Contributor

No changes to documentation

@stipsan stipsan disabled auto-merge May 31, 2024 10:52
@stipsan stipsan enabled auto-merge May 31, 2024 10:54
Copy link
Contributor

Component Testing Report Updated May 31, 2024 10:58 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 31s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 15s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 2s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 20s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 30s 12 0 0

@stipsan stipsan added this pull request to the merge queue May 31, 2024
Merged via the queue into next with commit 8ac0812 May 31, 2024
44 checks passed
@stipsan stipsan deleted the fix-pane-ref-forward-regression branch May 31, 2024 10:59
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.

2 participants