fix(ui-motion,ui-alerts): capture child DOM via elementRef in Transition to avoid React 'ref is not a prop' warning#2618
Open
joyenjoyer wants to merge 1 commit into
Open
fix(ui-motion,ui-alerts): capture child DOM via elementRef in Transition to avoid React 'ref is not a prop' warning#2618joyenjoyer wants to merge 1 commit into
joyenjoyer wants to merge 1 commit into
Conversation
…ion to avoid React 'ref is not a prop' warning
|
Visual regression report✅ No changes.
Baselines come from the |
ToMESSKa
requested changes
Jul 1, 2026
ToMESSKa
left a comment
Contributor
There was a problem hiding this comment.
@joyenjoyer This code snipper you attached does not animate:
function Repro() {
const [open, setOpen] = useState(false)
return (
<>
<button onClick={() => setOpen((o) => !o)}>toggle</button>
{/* View is a withStyle/forwardRef InstUI component; running the
transition re-clones it, which trips the warning on master */}
<Transition in={open} type="fade">
<View as="div" padding="small">Animated content</View>
</Transition>
</>
)
}
render(<Repro />)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BaseTransitionnow captures the child DOM node by branching ontypeof child.type: forwardRef/withStyle children go through theelementRefconvention (chained so a consumerelementRefstill fires), so React no longer readsrefas a prop and stops warning.refcallback withfindDOMNodeas the last-resort fallback.How it works (reviewer guide)
The lifecycle is unchanged — only how
this.ref(the child's DOM node) gets captured inrenderChildren()changed. Everything downstream still needs a real DOMElementby the timetransition()runs:The one changed decision — how the node is captured, keyed on
typeof child.type:Reproduction
Confirmed on this repo's React 18.3.1:
withStyleInstUI component (View,Alertcontent, …)`ref` is not a propwarning<div>/ plainforwardRefTwo conditions are both required — a static host child, or a mount that never runs a transition, will not show it:
withStyle-wrapped) component, sosafeCloneElementre-clones it.in={false}, or togglein(a staticin={true}mount withtransitionOnMount={false}won't).On master, initiating the transition logs
Warning: … `ref` is not a prop. Trying to access it will result in `undefined` being returned.; with this PR the warning is gone and the transition still animates.Test Plan
`ref` is not a propwarning is gone after the change (needs awithStylechild + an actually-run transition).Fixes LX-4014 INSTUI-5026
🤖 Generated with Claude Code