feat: warn ref usage on functional components
This commit is contained in:
parent
a651fc44f6
commit
7f054782ad
@ -804,6 +804,14 @@ export function createRenderer<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n2.ref !== null && parentComponent !== null) {
|
if (n2.ref !== null && parentComponent !== null) {
|
||||||
|
if (__DEV__ && !(n2.shapeFlag & ShapeFlags.STATEFUL_COMPONENT)) {
|
||||||
|
pushWarningContext(n2)
|
||||||
|
warn(
|
||||||
|
`Functional components do not support "ref" because they do not ` +
|
||||||
|
`have instances.`
|
||||||
|
)
|
||||||
|
popWarningContext()
|
||||||
|
}
|
||||||
setRef(n2.ref, n1 && n1.ref, parentComponent, n2.component!.renderProxy)
|
setRef(n2.ref, n1 && n1.ref, parentComponent, n2.component!.renderProxy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user