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

Move createElement/JSX Warnings into the Renderer #29088

Merged
merged 9 commits into from
May 23, 2024

Commits on May 23, 2024

  1. Configuration menu
    Copy the full SHA
    bde00cc View commit details
    Browse the repository at this point in the history
  2. Remove extra stack frame addendum indirections

    Eventually we should be able to delete describeUnknownElementTypeFrameInDEV
    since it only has this one callsite.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    8086702 View commit details
    Browse the repository at this point in the history
  3. Don't validate element type in createElement/JSX

    We validate these in the renderers inherently anyway and the renderers
    are the only ones that really knows what a valid type for that renderer is.
    
    For example the Client Reference check isn't valid for all kinds of configs
    in Flight. Also, a lot of the checks for valid elements are not valid in Flight
    e.g. class components.
    
    The only reason to do this validation early is because it provides a better
    stack trace of the callsite for context. However, that's a general problem
    and the whole point of enableOwnerStacks that it solves this for all kinds of
    late errors.
    
    For now I keep the early validation when enableOwnerStacks is off because
    in that case we don't have a good stack (but to be fair we don't for any
    other error neither). Once it is further rolled out we can delete these fully.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    c359809 View commit details
    Browse the repository at this point in the history
  4. Don't validate keys in createElement/JSX

    We have the same validation in the reconciler and with enableOwnerStacks
    we'll have the ability to provide a stack trace with the callsite of the
    element.
    
    The way the validation works is that if something is passed through a valid
    static slot, an element gets marked as valid. If it has been logged as errored
    before, it gets logged as valid so that future logs don't happen.
    
    This change logs for strictly fewer cases - specifically if an element doesn't
    get rendered/mounted at all. I updated some tests to start rendering where it
    didn't before.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    90971dc View commit details
    Browse the repository at this point in the history
  5. Mark child for force warning if assigned implicit key

    When React.Children assigns an implicit key we should still warn when the
    original element should've had a key since if was in an array.
    
    This marks such elements as having failed validation even if they have a
    key so that the error can later be logged in the renderer.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    8f6c117 View commit details
    Browse the repository at this point in the history
  6. Implement key warning in Fizz

    This is just additional for running warnings in the server logs in addition
    to the ones that happen during hydration but it's good to have both for
    parity and being able to fail SSR tests early.
    
    This also demonstrates per request warning deduping so that they don't just
    happen once when the server remains alive.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    caa9078 View commit details
    Browse the repository at this point in the history
  7. Validate key in Flight

    Elements that render Server Components are validated inside Flight.
    Others pass the validated flag to the client.
    
    Instead of running validation in certain cases (block list) we're marking
    all the cases that don't need keys (allow list) which is tricky since
    we need to cover all cases. This might lead to false warnings.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    06a041a View commit details
    Browse the repository at this point in the history
  8. Key warnings are no longer associated with a component in the tree

    Key warnings are supposed to be associated with the child missing the key.
    It was previously associated with the owner of the parent element which is
    not really as useful but now it's unfortunately associated with a fake
    fiber which disappears.
    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    047439c View commit details
    Browse the repository at this point in the history
  9. Fix keys in fixture

    sebmarkbage committed May 23, 2024
    Configuration menu
    Copy the full SHA
    43ceacd View commit details
    Browse the repository at this point in the history