Skip to content

Bug: Component is not a function when using Suspense and forwardRef #26385

Closed
@hansottowirtz

Description

@hansottowirtz

React version: 18.3.0-next-3ba7add60-20221201

Steps To Reproduce

I haven't been able to create a minimal example yet, if needed I will spend more time on it. However, it only seems to occur when Suspending components rerender in a specific order.

Description

The Component is not a function error is thrown when using Suspense and forwardRef together in a specific way.

It seems like react-reconciler doesn't properly handle forwardRefs in either renderWithHooksAgain, replaySuspendedComponentWithHooks, replayFunctionComponent or replaySuspendedUnitOfWork. The Component variable is not a function in this case, but a { $$typeof: Symbol(react.forward_ref), render: (props, ref) => any }. renderWithHooksAgain tries to execute Component(props, secondArg), which throws this error.

I'm not too familiar with React internals, if you can tell me how to trigger this codepath I can make a minimal reproduction more easily.

Screenshot 2023-03-14 at 14 55 13

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions