You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In React, when a ref is passed to a component, that component must forward the ref to a DOM element using React.forwardRef. If the Stack component does not implement forwardRef, the ref will not be attached to the underlying DOM element, resulting in ref.current being null or undefined.
import React, { useRef, useEffect } from 'react';
export function Example(props) {
const ref = useRef(null);
@iansan5653 I believe the types might be too loose for Stack which might be part of the problem here 🤔 The component does not currently support ref but the types seem to be allowing basically anything to be passed in so it has the appearance of being supported.
We've been trying to find a good way to do polymorphic as types and this seems to be a limitation with the approach we have 😅 Let me see if we can address that separately.
For Stack specifically, would it still be desirable for it to accept a ref? We can treat this as an enhancement then and get it added.
Stack
appears to accept aref
prop based on the TypeScript types, but this ref is not actually bound to the underlying element:If
Stack
correctly forwarded its ref, the console would log anHTMLDivElement
instance. However, it instead always logsnull
.The text was updated successfully, but these errors were encountered: