Commit Graph
16201 Commits
Author SHA1 Message Date
Tobias KoppersandGitHub abadeb29f3 fix incorrect insertion order of stylesheets (#28108)
## Summary

In the precendences Map every key is prefixed with `p`. This fixes one
case where this is missing.

## How did you test this change?

<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
  If you leave this empty, your PR will very likely be closed.
-->
2024-01-26 07:54:58 -08:00
Sebastian SilbermannandGitHub 72a8e88c55 Convert ChangeEventPlugin to createRoot (#28090) 2024-01-26 10:20:26 +01:00
Sebastian SilbermannandGitHub 3d975fcedd Convert ReactDOMAttribute to createRoot (#28089) 2024-01-26 10:17:26 +01:00
Sebastian SilbermannandGitHub 2234cf0330 Convert SelectEventPlugin to createRoot (#28076) 2024-01-26 10:17:13 +01:00
Sebastian SilbermannandGitHub f03ed9ebce Convert ReactDOMSVG to createRoot (#28074) 2024-01-26 10:17:09 +01:00
Matt CarrollandGitHub b971da1b9d Convert SyntheticWheelEvent-test.js to createRoot (#28103) 2024-01-26 03:05:08 -05:00
RickyandGitHub 05b009b156 Convert validateDOMNesting to createRoot (#28098)
ezpz
2024-01-25 22:30:56 -05:00
Andrew ClarkandGitHub 26b1531680 Async action support for React.startTransition (#28097)
This adds support for async actions to the "isomorphic" version of
startTransition (i.e. the one exported by the "react" package).
Previously, async actions were only supported by the startTransition
that is returned from the useTransition hook.

The interesting part about the isomorphic startTransition is that it's
not associated with any particular root. It must work with updates to
arbitrary roots, or even arbitrary React renderers in the same app. (For
example, both React DOM and React Three Fiber.)

The idea is that React.startTransition should behave as if every root
had an implicit useTransition hook, and you composed together all the
startTransitions provided by those hooks. Multiple updates to the same
root will be batched together. However, updates to one root will not be
batched with updates to other roots.

Features like useOptimistic work the same as with the hook version.

There is one difference from from the hook version of startTransition:
an error triggered inside an async action cannot be captured by an error
boundary, because it's not associated with any particular part of the
tree. You should handle errors the same way you would in a regular
event, e.g. with a global error event handler, or with a local
`try/catch`.
2024-01-25 21:54:45 -05:00
Sebastian MarkbĂĄgeandGitHub 3ea8608f22 [Flight/Fizz] Reset ThenableState Only in Branches Where It's Added (#28068)
Before, we used to reset the thenable state and extract the previous
state very early so that it's only the retried task that can possibly
consume it. This is nice because we can't accidentally consume that
state for any other node.

However, it does add a lot of branches of code that has to pass this
around. It also adds extra bytes on the stack per node. Even though it's
mostly just null.

This changes it so that where ever we can create a thenable state (e.g.
entering a component with hooks) we first extract this from the task.
The principle is that whatever could've created the thenable state in
the first place, must always be rerendered so it'll take the same code
paths to get there and so we'll always consume it.
2024-01-25 19:52:00 -05:00
Jan KassensandGitHub cbe7a60c5f Convert ReactLegacyContextDisabled-test.internal to createRoot (#28093)
Convert ReactLegacyContextDisabled-test.internal to createRoot
2024-01-25 16:02:13 -05:00
Jan KassensandGitHub ba0b13b136 Upgrade flow to 0.227.0 (#28094)
Upgrade flow to 0.227.0
2024-01-25 16:01:40 -05:00
Jan KassensandGitHub 0672d2737f Convert ReactFreshIntegration-test to createRoot (#28073)
Convert ReactFreshIntegration-test to createRoot
2024-01-25 15:07:57 -05:00
Jan KassensandGitHub b5aa7df104 Convert ReactDOMInput-test to createRoot (#28084)
Convert ReactDOMInput-test to createRoot
2024-01-25 14:22:12 -05:00
RickyandGitHub 3a4f2762d6 Convert ReactCompositeComponentState to createRoot (#28063) 2024-01-25 13:36:04 -05:00
Sebastian SilbermannandGitHub 88149c73d2 Convert ReactContextValidator to createRoot (#28085) 2024-01-25 18:37:07 +01:00
Jack PopeandGitHub 57a1702ffa Use createRoot in useFocus-test (#28083) 2024-01-25 12:10:56 -05:00
Sebastian MarkbĂĄgeandGitHub ec7b914cc4 [Flight] Refactor the Render Loop to Behave More Like Fizz (#28065)
This refactors the Flight render loop to behave more like Fizz with
similar naming conventions. So it's easier to apply similar techniques
across both. This is not necessarily better/faster - at least not yet.

This doesn't yet implement serialization by writing segments to chunks
but we probably should do that since the built-in parts that
`JSON.stringify` gets us isn't really much anymore (except serializing
strings). When we switch to that it probably makes sense for the whole
thing to be recursive.

Right now it's not technically fully recursive because each recursive
render returns the next JSON value to encode. So it's kind of like a
trampoline. This means we can't have many contextual things on the
stack. It needs to use the Server Context `__POP` trick. However, it
does work for things that are contextual only for one sequence of server
component abstractions in a row. Since those are now recursive.

An interesting observation here is that `renderModel` means that
anything can suspend while still serializing the outer siblings.
Typically only Lazy or Components would suspend but in principle a Proxy
can suspend/postpone too and now that is left serialized by reference to
a future value. It's only if the thing that we rendered was something
that can reduce to Lazy e.g. an Element that we can serialize it as a
lazy.

Similarly to how Suspense boundaries in Fizz can catch errors, anything
that can be reduced to Lazy can also catch an error rather than bubbling
it. It only errors when the Lazy resolves. Unlike Suspense boundaries
though, those things don't render anything so they're otherwise going to
use the destructive form. To ensure that throwing in an Element can
reuse the current task, this must be handled by `renderModel`, not for
example `renderElement`.
2024-01-25 12:09:11 -05:00
RickyandGitHub 6cdebf0f53 Update ReactUpdates-test (#28061)
## Overview

These tests are important for `ReactDOM.render`, so instead of just
re-writing them to `createRoot` and losing coverage:
- Moved the `.render` tests to `ReactLegacyUpdates`
- Re-wrote the tests in `ReactUpdates` to use `createRoot`
- Remove `unstable_batchedUpdates` from `ReactUpdates`

In a future PR, when I flag `batchedUpdates` with a Noop, I can add the
gate to just the tests in `ReactLegacyUpdates`.
2024-01-25 01:17:03 -05:00
RickyandGitHub 3d7d7e932a Convert ReactDOMFiber to createRoot (#28077)
Copies the existing tests to `ReactDOMLegacyFiber`, and updates
`ReactDOMFiber` to new root.
2024-01-24 23:55:42 -05:00
RickyandGitHub 3f84827915 Convert ReactMount to createRoot (#28075)
To convert this file, I started replacing all the calls in line, and
quickly realized that we already have most of these tests covered in
other files. So I found the test that we didn't already have for
`create/hydrateRoot` and added them, then renamed `ReactMount` to
`ReactLegacyMount`.
2024-01-24 23:55:21 -05:00
Andrew ClarkandGitHub aca9a01944 Batch async actions even if useTransition is unmounted (#28078)
If there are multiple updates inside an async action, they should all be
rendered in the same batch, even if they are separate by an async
operation (`await`). We currently implement this by suspending in the
`useTransition` hook to block the update from committing until all
possible updates have been scheduled by the action. The reason we did it
this way is so you can "cancel" an action by navigating away from the UI
that triggered it.

The problem with that approach, though, is that even if you navigate
away from the `useTransition` hook, the action may have updated shared
parts of the UI that are still in the tree. So we may need to continue
suspending even after the `useTransition` hook is deleted.

In other words, the lifetime of an async action scope is longer than the
lifetime of a particular `useTransition` hook.

The solution is to suspend whenever _any_ update that is part of the
async action scope is unwrapped during render. So, inside useState and
useReducer.

This fixes a related issue where an optimistic update is reverted before
the async action has finished, because we were relying on the
`useTransition` hook to prevent the optimistic update from finishing.

This also prepares us to support async actions being passed to the
non-hook form of `startTransition` (though this isn't implemented yet).
2024-01-24 23:54:53 -05:00
RickyandGitHub 36be91c4e7 Convert ReactDOMEventListener to createRoot (#28050) 2024-01-24 23:17:20 -05:00
RickyandGitHub baaa42cb09 Convert refs-destruction to createRoot (#28011) 2024-01-24 14:22:07 -05:00
RickyandGitHub 781a18f604 Use react@17 for useSyncExternalStore shim tests (#28055)
The tests for the shim need to test with ReactDOM.render in React 17.
2024-01-24 11:27:30 -05:00
RickyandGitHub 8d0160b783 Convert ReactCompositeComponentNestedState to createRoot (#28066) 2024-01-24 10:58:07 -05:00
RickyandGitHub 4dae8424a4 Convert ReactDOMFiberAsync to createRoot (#28067) 2024-01-24 10:57:47 -05:00
Jan KassensandGitHub 7a6cb8b558 Convert ReactServerRenderingHydration-test to createRoot (partially) (#28010)
Convert ReactServerRenderingHydration-test to createRoot (partially)

Some tests seem to be specifically testing the legacy APIs, maybe we
need to keep those around. Keeping this PR to the simple updates.
2024-01-24 10:38:28 -05:00
RickyandGitHub 77846a280d Convert ReactDOMTestSelectors-test.js to createRoot (#27993)
Straightforward adding createRoot and act
2024-01-23 23:01:53 -05:00
Jack PopeandGitHub 8d539901ab Use createRoot in ReactEventIndependence-test (#28052) 2024-01-23 17:33:49 -05:00
Jack PopeandGitHub bfad197675 Use createRoot in ReactART-test (#28060)
Stacked on #28059

---------
2024-01-23 17:25:18 -05:00
Jack PopeandGitHub 44905f447e Remove ReactTestUtils from ReactArt-test (#28059) 2024-01-23 17:05:01 -05:00
Jan KassensandGitHub 3f2e44035a Convert ReactDOMComponent-test to createRoot (#28034)
Convert ReactDOMComponent-test to createRoot
2024-01-23 10:04:13 -05:00
Jan KassensandGitHub 0e6805cfb3 Fix ReactFreshIntegration-test not running all tests as assumed (#28033)
Fix ReactFreshIntegration-test not running all tests as assumed

`testCommon` was executed twice without setting `compileDestructuring`
ever to true.
This fixes this and removes one layer of abstraction in this test by
using `describe.each`.
2024-01-23 09:59:14 -05:00
Sebastian SilbermannandGitHub 6f77a62549 Convert ReactMountDestruction (partially) to createRoot (#28004) 2024-01-23 10:30:19 +01:00
Jack PopeandGitHub 347a6b9b03 Use createRoot for ReactTreeTraversal-test (#28051) 2024-01-22 17:13:10 -05:00
RickyandGitHub 890fa2d99b Convert ReactElementJSX to createRoot (#28012) 2024-01-22 15:50:20 -05:00
Sebastian SilbermannandGitHub faa6ac2fd2 Convert describeComponentFrame to createRoot (#28001) 2024-01-22 15:08:39 +01:00
Sebastian SilbermannandGitHub 905acc3342 Convert ReactDOMOption to createRoot (#28002) 2024-01-22 09:21:40 +01:00
RickyandGitHub 46783ef0cd Convert ReactError-test to createRoot (#27995) 2024-01-19 14:35:56 -05:00
Jan KassensandGitHub 6305b100b2 Convert getEventKey-test to createRoot (#28006)
Convert getEventKey-test to createRoot
2024-01-19 13:51:20 -05:00
Jan KassensandGitHub 651b9f60e0 Convert ReactUpdaters-test.internal to createRoot (#28005)
Convert ReactUpdaters-test.internal to createRoot
2024-01-19 13:37:10 -05:00
Jan KassensandGitHub bd8ef8a7d2 Convert SyntheticKeyboardEvent-test to createRoot (#28007)
Convert SyntheticKeyboardEvent-test to createRoot
2024-01-19 13:36:05 -05:00
Jan KassensandGitHub df8c0f0954 Convert dangerouslySetInnerHTML-test to createRoot (#28008)
Convert dangerouslySetInnerHTML-test to createRoot
2024-01-19 13:35:43 -05:00
Jan KassensandGitHub 73293e55f1 Convert ReactDOM-test to createRoot (#28009)
Convert ReactDOM-test to createRoot
2024-01-19 13:35:15 -05:00
Sebastian SilbermannandGitHub 52cacab8f4 Convert ReactFreshMultipleRenderer to createRoot (#28000) 2024-01-19 18:21:15 +01:00
Sebastian SilbermannandGitHub 1495990002 Convert ReactErrorLoggingRecovery to createRoot (#28003) 2024-01-19 18:07:08 +01:00
RickyandGitHub 15aba427a6 Convert ReactFunctionComponent to createRoot (#27997) 2024-01-18 22:32:04 -05:00
a08b2ed78e Update error decoder URL (#27240)
Updates the error decoder to the URL for the new docs site.

- Switches the domain from reactjs.org to react.dev
- Switches to put the error code in the URL for SSG
- All params are still in the query

Example without args:

- Before: `https://reactjs.org/docs/error-decoder.html?invariant=200`
- After: ` https://react.dev/errors/200`

Example with args:
- Before:
`https://reactjs.org/docs/error-decoder.html?invariant=124?args[]=foo&args[]=bar
`
- After: ` https://react.dev/errors/124?args[]=foo&args[]=bar`


Requires: https://github.com/reactjs/react.dev/pull/6214

---------

Co-authored-by: Jan Kassens <[email protected]>
2024-01-17 21:41:07 -05:00
Andrew ClarkandGitHub b22798cec1 Remove client caching from cache() API (#27977)
We haven't yet decided how we want `cache` to work on the client. The
lifetime of the cache is more complex than on the server, where it only
has to live as long as a single request.

Since it's more important to ship this on the server, we're removing the
existing behavior from the client for now. On the client (i.e. not a
Server Components environment) `cache` will have not have any caching
behavior. `cache(fn)` will return the function as-is.

We intend to implement client caching in a future major release. In the
meantime, it's only exposed as an API so that Shared Components can use
per-request caching on the server without breaking on the client.
2024-01-16 20:27:15 -05:00
Andrew ClarkandGitHub 7986ebd441 Refactor React Server entrypoint to not depend on the client one (#27940)
This refactors the Server Components entrypoint for the `react` package
(ReactServer.js) so that it doesn't depend on the client entrypoint
(React.js). I also renamed React.js to ReactClient.js to make the
separation clearer.

This structure will make it easier to add client-only and server-only
features.
2024-01-16 20:19:01 -05:00