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

Detect and warn about native async function components in development #27031

Merged
merged 1 commit into from
Jul 2, 2023

Commits on Jul 2, 2023

  1. Detect native async function components in dev

    Adds a development warning to complement the error introduced by facebook#27019.
    
    We can detect and warn about async client components by checking the
    prototype of the function. This won't work for environments where async
    functions are transpiled, but for native async functions, it allows us
    to log an earlier warning during development, including in cases that
    don't trigger the infinite loop guard added in facebook#27019. It does not
    supersede the infinite loop guard, though, because that mechanism also
    prevents the app from crashing.
    
    I also added a warning for calling a hook inside an async function. This
    one fires even during a transition. We could add a corresponding warning
    to Flight, since hooks are not allowed in async Server Components,
    either. (Though in both environments, this is better handled by a
    lint rule.)
    acdlite committed Jul 2, 2023
    Configuration menu
    Copy the full SHA
    b4b0526 View commit details
    Browse the repository at this point in the history