Commit Graph
606 Commits
Author SHA1 Message Date
rickhanlonii b2e00b2d71 Add ReactDOMClient to ServerIntegrationReconnecting (#28136)
## Overview

Branched off https://github.com/facebook/react/pull/28130

## Why

In https://github.com/facebook/react/pull/24276 we changed the new root
behavior to error when a client-render is forced for certain cases, so
these now expect a mismatch even though they're using
`suppressHydrationWarning`.

DiffTrain build for commit https://github.com/facebook/react/commit/4bd5e3ea5c449fdd2089f6bdfb07fb1120b0eec7.
2024-02-01 23:37:11 +00:00
rickhanloniiandSebastian Silbermann bdb7f3383a Add ReactDOMClient to ServerIntegration(Hooks|NewContext) (#28135)
## Overview

Branched off https://github.com/facebook/react/pull/28130

### ~Failing~ Fixed by @eps1lon
Most of the tests pass, but there are 3 tests that have additional
warnings due to client render error retries.

For example, before we would log:

```
Warning: Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks.
Warning: Expected server HTML to contain a matching text node for "0" in <div>.
```

And now we log

```
Warning: Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks.
Warning: Expected server HTML to contain a matching text node for "0" in <div>.
Warning: Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks.
```

We can't just update the expected error count for these tests, because
the additional error only happens on the client. So I need some guidance
on how to fix these.

---------

Co-authored-by: Sebastian Silbermann <sebastian.silbermann@klarna.com>

DiffTrain build for commit https://github.com/facebook/react/commit/fa6674b5bcf52610e92d19a5105308e56091c386.
2024-02-01 23:37:02 +00:00
rickhanlonii e5162748dd Add ReactDOMClient to ServerIntegrationBasic (#28133)
## Overview

Branched off https://github.com/facebook/react/pull/28130

In `hydrateRoot`, we now error if you pass `undefined`:

```
Warning: Must provide initial children as second argument to hydrateRoot.
```

So we expect 1 error for this now.

DiffTrain build for commit https://github.com/facebook/react/commit/278199b3deeee73f969a242c777c2d38406f8bfe.
2024-02-01 23:36:52 +00:00
rickhanloniiandSebastian Silbermann 6dbde82acd Add ReactDOMClient to ServerIntegrationElements (#28134)
## Overview

Branched off https://github.com/facebook/react/pull/28130

## ~Failing~ Fixed by @eps1lon

The tests are currently failing because of two tests covering special
characters. I've tried a few ways to fix, but I'm stuck and will need
some help understanding why they fail and how to fix.

---------

Co-authored-by: Sebastian Silbermann <sebastian.silbermann@klarna.com>

DiffTrain build for commit https://github.com/facebook/react/commit/c0d927713002fe27c4d58717d35cd930e6814c2b.
2024-02-01 23:36:36 +00:00
rickhanlonii 029d7354ae Add ReactDOMClient to ServerIntegrationSelect (#28132)
## Overview

Branched off https://github.com/facebook/react/pull/28130

## React for count changing
### Before
These tests are weird because on main they pass, but log to the console:

```
We expected 2 warning(s), but saw 1 warning(s).
We saw these warnings:
    Warning: Expected server HTML to contain a matching <select> in <div>.
        at select
```

The other one is ignored. The `expect(console.errors).toBeCalledWith(2)`
doesn't account for ignored calls, so the test passes with the two
expected (the +1 is in the test utiles). The ignored warning is

```
Warning: ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead.
```

So the mismatch is in the ignored warnings.

### After

After switching to `createRoot`, it still logs:

```
We expected 2 warning(s), but saw 1 warning(s).
We saw these warnings:
    Warning: Expected server HTML to contain a matching <select> in <div>.
        at select
```

But the test fails due to an unexpected error count. The new ignored
errors are:

```
Error: Uncaught [Error: Hydration failed because the initial UI does not match what was rendered on the server.]
Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>.
Error: Hydration failed because the initial UI does not match what was rendered on the server.
Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.
```

These seem to be the correct warnings to fire in `createRoot`, so the
fix is to update the number of warnings we expect.

DiffTrain build for commit https://github.com/facebook/react/commit/c42e7c7adc3a036c0c176d5b3dd7cf9215862815.
2024-02-01 23:35:26 +00:00
rickhanlonii 06365e83b3 Add ReactDOMClient to ServerIntegrationTestUtils (#28130)
## Overview

Adds support for `ReactDOMClient` for  `ServerIntegration*` tests.

Also converts tests that pass without any other changes. Will follow up
with other PRs for more complex cases.

DiffTrain build for commit https://github.com/facebook/react/commit/6054be9c86f2e01e5e24c1fe2182479fec8667e4.
2024-02-01 23:30:07 +00:00
eps1lon 32584c137a fix(eslint-plugin-react-hooks): accepting as expression as a callback (#28202)
## Summary

Closes #20750

## How did you test this change?

Added a test case

DiffTrain build for commit https://github.com/facebook/react/commit/2efa38332adc1fc1500753d79fcba41a0197a7a6.
2024-02-01 20:11:52 +00:00
rickhanlonii ea5df469a7 Remove createRootStrictEffectsByDefault flag (#28102)
There's no need to separate strict mode from strict effects mode any
more.

I didn't clean up the `StrictEffectMode` fiber flag, because it's used
to prevent strict effects in legacy mode. I could replace those checks
with `LegacyMode` checks, but when we remove legacy mode, we can remove
that flag and condense them into one StrictMode flag away.

DiffTrain build for commit https://github.com/facebook/react/commit/3d1da1f9ab7d54984c096e6a04c8729f3a50fd8a.
2024-02-01 19:59:01 +00:00
noahlemen e12f0de391 convert ReactElement-test from renderIntoDocument (#28161)
## Summary

refactors ReactElement-test to use `createRoot` instead of
`renderIntoDocument`, which uses `ReactDOM.render` under the hood

## How did you test this change?
`yarn test ReactElement`

DiffTrain build for commit https://github.com/facebook/react/commit/4dd475c97799f3fb83bdd2fff2d028e0e30041cf.
2024-02-01 19:54:25 +00:00
noahlemen 638cff4dcb convert ReactElementClone-test from renderIntoDocument (#28193)
## Summary

migrates to createRoot – renderIntoDocument uses ReactDOM.render

## How did you test this change?

yarn test ReactElementClone

DiffTrain build for commit https://github.com/facebook/react/commit/94259cd57a72123af224d6786c96f5915de06d63.
2024-02-01 19:49:44 +00:00
rickhanlonii e6b17cab9a Update react docs link in issue template (#28195)
DiffTrain build for commit https://github.com/facebook/react/commit/6f8f0005926cc1cdf1d12b3e1c2cc9fce1a17baa.
2024-02-01 19:49:06 +00:00
eps1lon 86906e876a fix(eslint-plugin-react-hooks): accepting as expressions as deps array (#28189)
## Summary

This PR closes #25844
The original issue talks about `as const`, but seems like it fails for
any `as X` expressions since it adds another nesting level to the AST.

EDIT: Also closes #20162

## How did you test this change?

Added unit tests

DiffTrain build for commit https://github.com/facebook/react/commit/a1433ca0bacff76f720ffec9a0020f56e8c9ffed.
2024-02-01 19:34:51 +00:00
acdlite 7cec0cb5a5 Add stable React.act export (#28160)
Starting in version 19, users can import the `act` testing API from the
`react` package instead of using a renderer specific API, like
`react-dom/test-utils`.

DiffTrain build for commit https://github.com/facebook/react/commit/53b12e46a17549ec7644e13c126440ed2f3629fd.
2024-02-01 18:33:51 +00:00
kassens d9e1e76e05 [flow] ignore hidden directories (#28096)
[flow] ignore hidden directories

DiffTrain build for commit https://github.com/facebook/react/commit/4384a7bcd351c2218c5727a949cf7fff20c3d9d4.
2024-02-01 16:29:01 +00:00
gnoff 012c527201 [Fizz] Support aborting with Postpone (#28183)
Semantically if you make your reason for aborting a Postpone instance
the render should not hit the error pathways but should instead follow
the postpone pathways. It's awkward today to actually get your hands on
a Postpone instance because you have to catch the throw from postpone
and then pass that into `abort()` or `AbortController.abort()`
(depending on the renderer API you are using)

This change makes it so that in most circumstances if you abort with a
postpone the `onPostpone` handler will be called and the Suspense
boundaries still pending will be put into client render mode with the
appropriate postpone digest to avoid trigger recoverable error pathways
on the client.

Similar to postponing in the shell during a resume or render however if
you abort before the shell is complete in a resume or render we will
fatally error. The fatal error is contextualized by React to avoid
passing the postpone object itself to the `onError` and related options.

DiffTrain build for commit https://github.com/facebook/react/commit/1219d57fc9fcbf44c873c0b10e5acbd31f613c15.
2024-02-01 15:18:47 +00:00
gnoff bedf028f20 Enable enableFilterEmptyStringAttributesDOM everywhere (#28125)
## Summary

Stacked on [#28124](https://github.com/facebook/react/pull/28124) ([Diff
against
#28124](https://github.com/facebook/react/compare/eps1lon:fix/anchor-href-empty...eps1lon:feat/enableFilterEmptyStringAttributesDOM-canary))

Enables `enableFilterEmptyStringAttributesDOM` everywhere. I don't think
this needs to be enabled behind `__VARIANT__` for RN since this flag is
only used in DOM.

## How did you test this change?

- CI

DiffTrain build for commit https://github.com/facebook/react/commit/d29f7d973da616a02d6240ea10306a6f33e35ca1.
2024-01-31 16:28:12 +00:00
hoxyq 883d077f60 chore: remove eslint-plugin-flowtype from dev dependencies (#28157)
While trying to resolve some issues with Flow in ESLint, noticed that we
are still listing `eslint-plugin-flowtype` as dev dependency, but it has
been deprecated in favour of `eslint-plugin-ft-flow`.

DiffTrain build for commit https://github.com/facebook/react/commit/f7ce4164c90990bd43b2671bf0b1db45e160fc15.
2024-01-31 14:58:52 +00:00
rickhanlonii 948ac0625e Add script to output flag values (#28115)
## Overview

Depends on: https://github.com/facebook/react/pull/28116

Add `yarn flags` to output at table of all feature flags.

Provides options to output a csv file, diff two or more builds, and
sort.

### Options
<img width="1154" alt="Screenshot 2024-01-26 at 4 06 53 PM"
src="https://github.com/facebook/react/assets/2440089/c3dbd632-adb9-4416-9488-1c603ee4e789">

### `yarn flags --diff next canary`
<img width="637" alt="Screenshot 2024-01-26 at 4 15 03 PM"
src="https://github.com/facebook/react/assets/2440089/1a681ae8-ce33-42d0-9d1f-3f415a8e1c3d">

### `yarn flags --diff canary experimental`
<img width="637" alt="Screenshot 2024-01-26 at 4 14 51 PM"
src="https://github.com/facebook/react/assets/2440089/c66f66cb-3cee-4df6-a1d1-b24600ebd4b3">

### `yarn flags` (all flags)

<img width="1054" alt="Screenshot 2024-01-26 at 4 16 30 PM"
src="https://github.com/facebook/react/assets/2440089/4ce99c7c-825e-4bca-9b83-ca5d6e2bc1a9">

DiffTrain build for commit https://github.com/facebook/react/commit/45582c6c4d8b73229c71febbba43ee60fbab81fb.
2024-01-31 04:20:24 +00:00
eps1lon fb5983331a Restore old behavior for empty href props on anchor tags (#28124)
Treat `<a href="" />` the same with and without
`enableFilterEmptyStringAttributesDOM`

in https://github.com/facebook/react/pull/18513 we started to warn and
ignore for empty `href` and `src` props since it usually hinted at a
mistake. However, for anchor tags there's a valid use case since `<a
href=""></a>` will by spec render a link to the current page. It could
be used to reload the page without having to rely on browser
affordances.

The implementation for Fizz is in the spirit of
https://github.com/facebook/react/pull/21153. I gated the fork behind
the flag so that the fork is DCE'd when the flag is off.

DiffTrain build for commit https://github.com/facebook/react/commit/f3ce87ab650f07774e1df9bc3f8033e023973d10.
2024-01-30 23:48:33 +00:00
eps1lon 040cfcd669 Convert trustedTypes to createRoot (#28163)
DiffTrain build for commit https://github.com/facebook/react/commit/af7e8c7a71c60278e3935dfb20fac7b562769bb4.
2024-01-30 21:27:31 +00:00
eps1lon 9c3dd79b95 Convert SimpleEventPlugin to createRoot (#28164)
DiffTrain build for commit https://github.com/facebook/react/commit/13aae52aea07b59b17aebaf65fd83d1c67c6ecb4.
2024-01-30 21:25:55 +00:00
rickhanlonii 35032e7102 Update www flags (#28150)
Adds an experiment for `enableFormActions` and hardcodes
`enableCustomElementPropertySupport` on www since this is shipped.

DiffTrain build for commit https://github.com/facebook/react/commit/417188314dd1d6df54efc8cd6a0c5d4830615888.
2024-01-30 19:29:35 +00:00
acdlite 2b3922a68b Always warn if client component suspends with an uncached promise (#28159)
Previously we only warned during a synchronous update, because we
eventually want to support async client components in controlled
scenarios, like during navigations. However, we're going to warn in all
cases for now until we figure out how that should work.

DiffTrain build for commit https://github.com/facebook/react/commit/178f4351947a842ff0b56700e9115b25ae8f20d0.
2024-01-30 19:28:14 +00:00
gnoff 47a7b36bbd [Fizz] improve Hoistable handling for Elements and Resources inside Suspense Boundaries (#28069)
Updates Fizz to handle Hoistables (Resources and Elements) in a way that
better aligns with Suspense fallbacks

1. Hoistable Elements inside a fallback (regardless of how deep and how
many additional boundaries are intermediate) will be ignored. The
reasoning is fallbacks are transient and since there is not good way to
clean up hoistables because they escape their Suspense container its
better to not emit them in the first place. SSR fallbacks are already
not full fidelity because they never hydrate so this aligns with that
somewhat.
2. Hoistable stylesheets in fallbacks will only block the reveal of a
parent suspense boundary if the fallback is going to flush with that
completed parent suspense boundary. Previously if you rendered a
stylesheet Resource inside a fallback any parent suspense boundaries
that completed after the shell flushed would include that resource in
the set required to resolve before the boundary reveal happens on the
client. This is not a semantic change, just a performance optimization
3. preconnect and preload hoistable queues are gone, if you want to
optimize resource loading you shoudl use `ReactDOM.preconnect` and
`ReactDOM.preload`. `viewport` meta tags get their own queue because
they need to go before any preloads since they affect the media state.

In addition to those functional changes this PR also refactors the
boundary resource tracking by moving it to the task rather than using
function calls at the start of each render and flush. Tasks also now
track whether they are a fallback task

supercedes prior work here: https://github.com/facebook/react/pull/27534

DiffTrain build for commit https://github.com/facebook/react/commit/554fc49f41465d914b15dc8eb2ec094f37824f7e.
2024-01-30 18:20:40 +00:00
gnoff cb419ffe0a [Fiber] Use a safer strategy to track the last precedence (#28110)
Uses a safer strategy to track the last precedence to avoid the need to
consistently remember to preprend `'p'` to the precedence value

DiffTrain build for commit https://github.com/facebook/react/commit/1c958aa4abf9e6b638489b1d73cdb1b6dc7c3ab6.
2024-01-30 18:15:00 +00:00
eps1lon 468b3d6ceb Complete DOMPluginEventSystem migration to createRoot (#28148)
Follow-up to
https://github.com/facebook/react/pull/28139#discussion_r1468852457

I mistakenly kept the tests using comment nodes as containers as legacy
tests. It's not that comments nodes aren't allowed in createRoot
entirely. Only behind `disableCommentsAsDOMContainers`. We already had
one test following that pattern so I just applied the same pattern to
the other tests for consistency.

Now `DOMPluginEventSystem` no longer uses any legacy roots.

DiffTrain build for commit https://github.com/facebook/react/commit/2477384650bd184d3ac4a881130118f2636f8551.
2024-01-30 08:16:33 +00:00
rickhanlonii 68cf918290 Clean up experimental flags (#28116)
## Overview

Adds a new global to disambiguate experimental flags that we intend to
land when we can make breaking changes.

DiffTrain build for commit https://github.com/facebook/react/commit/4d6c47baa3bf40bb7dea23642dd42e97eba4232d.
2024-01-29 19:08:11 +00:00
rickhanlonii 93c8e4a823 Convert ReactCompositeComponent to createRoot (#28099)
Moves tests depending on legacy APIs to `ReactLegacyCompositeComponents`
and updates the rest.

DiffTrain build for commit https://github.com/facebook/react/commit/4c73da8cbdbd2493827f86ed1991c3770ecb9625.
2024-01-29 19:07:49 +00:00
rickhanlonii b2fc9d3eaf Remove duplicate dynamic scheduler flags (#28100)
These were made dynamic again in
https://github.com/facebook/react/pull/27919, and already have the
dynamic flags set. It's a bummer to push this around, we should come up
with a better way.

DiffTrain build for commit https://github.com/facebook/react/commit/61df8caa3b96a0395b550d8c2a3dca7269761d55.
2024-01-29 18:44:19 +00:00
rickhanlonii 3789d11dbb Add lint tests that should fail (#28147)
These though fail.

Anon default export: https://github.com/facebook/react/issues/21181
Promise callbacks: https://github.com/facebook/react/issues/26186
Returning anon functions: https://github.com/facebook/react/issues/22520

DiffTrain build for commit https://github.com/facebook/react/commit/cc7d4216299e1d23a6e77b58d4c32ec1b8864ead.
2024-01-29 17:59:21 +00:00
eps1lon 272139fecc Convert useFocusWithin to createRoot (#28128)
DiffTrain build for commit https://github.com/facebook/react/commit/971b62f479a5dbd84688ba2b2c507de2a1d22dcc.
2024-01-29 16:07:30 +00:00
eps1lon 0523b87030 Convert ReactDOMTextarea to createRoot (#28126)
Also removes usage of `ReactTestUtils`

DiffTrain build for commit https://github.com/facebook/react/commit/cdfaae73c4768ddcce724872b1aa45130b39c85f.
2024-01-29 16:07:12 +00:00
eps1lon 4f379ca8dc Convert DOMPluginEventSystem to createRoot (#28139)
DiffTrain build for commit https://github.com/facebook/react/commit/00d42ac3542179c55f936f395ede7abaeb5900a3.
2024-01-29 08:17:01 +00:00
eps1lon 04bf1208cf Convert ReactMultiChildText to createRoot (#28140)
DiffTrain build for commit https://github.com/facebook/react/commit/6d2a1d0334581c1cdb269863f6a73d152a671c49.
2024-01-29 08:16:25 +00:00
eps1lon 7f49dcdc80 Convert ReactDOMTextComponent to createRoot (#28141)
DiffTrain build for commit https://github.com/facebook/react/commit/313e4d4129088b3ed99ab64d15dd8b6de175261b.
2024-01-29 08:16:03 +00:00
eps1lon 9801e9a7a6 Convert ReactDOMSelect to createRoot (#28142)
DiffTrain build for commit https://github.com/facebook/react/commit/1c8901f750fe09396de311e9c9e1e337599b2e9c.
2024-01-29 08:15:12 +00:00
eps1lon 07e3116245 Convert refs to createRoot (#28113)
DiffTrain build for commit https://github.com/facebook/react/commit/7aa45db6a2d30e62cf5ace08e17d971c8e8b977c.
2024-01-28 09:46:39 +00:00
rickhanlonii e5d6f17904 Convert ReactDOMInvalidARIAHook to createRoot (#28129)
DiffTrain build for commit https://github.com/facebook/react/commit/3e58b0af0caebf5f1b507ce5f360c85cb57bf528.
2024-01-27 21:12:32 +00:00
rickhanloniiandRicky 1597e9d1b5 Convert renderSubtreeIntoContainer-test.js to createRoot (#28114)
Co-authored-by: Ricky <rickhanlonii@gmail.com>

DiffTrain build for commit https://github.com/facebook/react/commit/e2b93afc604f857f7b59788920533ff7d1c72563.
2024-01-27 00:34:58 +00:00
rickhanloniiandJack Pope 3e90bd4cb9 Clean up legacy render from ReactTestUtilsAct-test (#28091)
Co-authored-by: Jack Pope <jackpope@meta.com>

DiffTrain build for commit https://github.com/facebook/react/commit/91212b09ed53c8d5a0f414ed93972681caa5ac7e.
2024-01-27 00:34:04 +00:00
rickhanloniiandJack Pope b90ac83277 Remove ReactDOM.render tests in ReactDOMConsoleErrorReporting-test (#28053)
Each it block here was duplicated to cover ReactDOM.render and
ReactDOMClient.createRoot. Here we delete the ReactDOM.render coverage.

Co-authored-by: Jack Pope <jackpope@meta.com>

DiffTrain build for commit https://github.com/facebook/react/commit/407faf5a69955f23f3549cff77b1a37199daa95f.
2024-01-27 00:33:25 +00:00
rickhanloniiandJack Pope 6e98113f0d Use createRoot in ReactMockedComponent-test (#28087)
Co-authored-by: Jack Pope <jackpope@meta.com>

DiffTrain build for commit https://github.com/facebook/react/commit/54f2314e9cfe82baf1c040a55ed4dfff6488f84e.
2024-01-26 22:33:38 +00:00
jackpope 1dd48c66f9 Use createRoot in ReactDOMComponentTree-test (#28112)
DiffTrain build for commit https://github.com/facebook/react/commit/4c41c09ccc28e5cf85cbb706908b740c95ff5a97.
2024-01-26 22:22:55 +00:00
jackpope b446d3cf92 Use createRoot in ReactTestUtilsActUnmockedScheduler-test (#28086)
DiffTrain build for commit https://github.com/facebook/react/commit/38997cf19ac5223a7c748ba975b40d649b9c4c52.
2024-01-26 22:22:16 +00:00
rickhanlonii 9fb3f6b0dc Remove outdated enableSchedulerDebugging flag (#28101)
This flag was moved to the scheduler feature flags, so these flags don't
do anything.

DiffTrain build for commit https://github.com/facebook/react/commit/766eac46bb52bda28f87c11740214a4444ca881b.
2024-01-26 21:57:40 +00:00
mattcarrollcode 351812c26b Convert ReactIdentity-test.js to createRoot (#28106)
DiffTrain build for commit https://github.com/facebook/react/commit/37bdff675c28e247333ffe35055534ad94941e8c.
2024-01-26 21:23:44 +00:00
mattcarrollcode 8b5b558fee Convert ReactMultiChild-test.js to createRoot (#28117)
DiffTrain build for commit https://github.com/facebook/react/commit/759811b0627384e5dde8ac81397cb2b8c7390298.
2024-01-26 21:22:51 +00:00
mattcarrollcode f62f2e6e21 Convert SyntheticEvent-test.js to createRoot (#28118)
DiffTrain build for commit https://github.com/facebook/react/commit/8f998bf93fdc417ea9e8f99dedfe3a7c3d6e5bbc.
2024-01-26 21:22:36 +00:00
mattcarrollcode d9e12f1d74 Convert ReactDOMServerIntegrationUntrustedURL-test.js to createRoot (#28105)
DiffTrain build for commit https://github.com/facebook/react/commit/7c79dafb71cab8808749e3284eab3c623e9c2360.
2024-01-26 20:21:53 +00:00
eps1lon b6a6c643fe Use modern rendering APIs for attribute-behavior fixture (#27883)
The attribute-behavior fixture now uses `createRoot().render()` and
`renderToReadableStream` instead of depdrecated APIs.

This revealed some changes to the snapshots that I annotated for
discussion.

I also added some new tests related to upcoming changes for easier
future diffing.

Also adds support for running the attribute-behavior fixture using Apple
Silicon chips (Apple MBP M-series).

DiffTrain build for commit https://github.com/facebook/react/commit/9aef5d225b489ceeba753c5c86b236259baf816c.
2024-01-26 18:08:34 +00:00