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

Bug: Fix suspense replaying forward refs #32218

Open
Keston375 opened this issue Jan 24, 2025 · 0 comments
Open

Bug: Fix suspense replaying forward refs #32218

Keston375 opened this issue Jan 24, 2025 · 0 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@Keston375
Copy link

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.

React version:
18.3.0-next-3ba7add60-20221201

Steps To Reproduce

  1. occur when Suspending components rerender in a specific order.

Expected Behavior

  • Components using forwardRef wrapped in Suspense should render correctly without errors during the replay of suspended units of work.
  • The replaySuspendedUnitOfWork function should correctly identify and handle forwardRef components by invoking their render method.

Current Behavior

  • When a forwardRef component is wrapped with Suspense and a suspension occurs, React throws a "Component is not a function" error during the replay phase.
  • The replaySuspendedUnitOfWork function attempts to invoke the type property directly, which is not appropriate for forwardRef components, leading to the error.
@Keston375 Keston375 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Jan 24, 2025
@Keston375 Keston375 changed the title Bug: Bug: Fix suspense replaying forward refs Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant