Commit Graph

16266 Commits

Author SHA1 Message Date
Sebastian Silbermann f8b26862d6 Convert CSSProperty to createRoot (#28181) 2024-02-02 09:14:43 +01:00
Sebastian Silbermann f28f022f22 Convert InvalidEventListeners to createRoot (#28180) 2024-02-02 09:14:34 +01:00
Sebastian Silbermann e9c13cde64 Convert ReactComponentLifeycle to createRoot (#28178) 2024-02-02 09:14:25 +01:00
Sebastian Silbermann 11aa263844 Remove usage of /test-utils in ReactLegacyCompositeComponent (#28201) 2024-02-02 09:14:05 +01:00
Sebastian Silbermann 7f8798a3f2 Convert ReactDOMSelection to createRoot (#28176) 2024-02-02 08:58:30 +01:00
Sebastian Silbermann fa8a34bfac Convert ReactStrictMode to createRoot (#28162) 2024-02-02 08:57:56 +01:00
Ricky b25dcd3958 Add ReactDOMClient to ServerIntegration tests (minor fixes) (#28131)
## Overview 

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

Converts to `createRoot`, with a few additional in-line conversions in
each file.
2024-02-01 19:01:16 -05:00
Sebastian Silbermann 2a45118b10 Convert ResponderEventPlugin to createRoot (#28190) 2024-02-01 18:53:25 -05:00
Sebastian Silbermann 2dc428f746 Convert ReactScope to createRoot (#28172) 2024-02-01 18:51:10 -05:00
Sebastian Silbermann 44952dc984 Convert ReactComponent to createRoot (#28171) 2024-02-01 18:50:38 -05:00
Sebastian Silbermann a7f1622117 Convert SyntheticFocusEvent to createRoot (#28173) 2024-02-01 18:49:40 -05:00
Sebastian Silbermann bc219090e3 Convert SyntheticClipboardEvent to createRoot (#28174) 2024-02-01 18:49:18 -05:00
Sebastian Silbermann c39ec17e66 Convert ReactErrorBoundariesHooks to createRoot (#28175) 2024-02-01 18:48:58 -05:00
Ricky 4bd5e3ea5c 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`.
2024-02-01 18:32:38 -05:00
Ricky fa6674b5bc 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>
2024-02-01 18:32:27 -05:00
Ricky c0d9277130 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>
2024-02-01 18:32:18 -05:00
Ricky 278199b3de 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.
2024-02-01 18:32:04 -05:00
Ricky c42e7c7adc 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.
2024-02-01 18:31:52 -05:00
Ricky 6054be9c86 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.
2024-02-01 18:26:33 -05:00
StyleShit 2efa38332a 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
2024-02-01 21:08:21 +01:00
Ricky 3d1da1f9ab 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.
2024-02-01 14:54:20 -05:00
Noah Lemen 4dd475c977 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`
2024-02-01 14:49:30 -05:00
Noah Lemen 94259cd57a convert ReactElementClone-test from renderIntoDocument (#28193)
## Summary

migrates to createRoot – renderIntoDocument uses ReactDOM.render

## How did you test this change?

yarn test ReactElementClone
2024-02-01 14:45:06 -05:00
Ricky 6f8f000592 Update react docs link in issue template (#28195) 2024-02-01 14:44:26 -05:00
StyleShit a1433ca0ba 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
2024-02-01 20:30:17 +01:00
Andrew Clark 53b12e46a1 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`.
2024-02-01 13:28:14 -05:00
Jan Kassens 4384a7bcd3 [flow] ignore hidden directories (#28096)
[flow] ignore hidden directories
2024-02-01 11:24:04 -05:00
Josh Story 1219d57fc9 [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.
2024-02-01 07:14:08 -08:00
Sebastian Silbermann d29f7d973d 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
2024-01-31 08:23:21 -08:00
Ruslan Lesiutin f7ce4164c9 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`.
2024-01-31 14:52:52 +00:00
Ricky 45582c6c4d 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">
2024-01-30 23:15:50 -05:00
Sebastian Silbermann f3ce87ab65 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.
2024-01-31 00:43:40 +01:00
Sebastian Silbermann af7e8c7a71 Convert trustedTypes to createRoot (#28163) 2024-01-30 22:22:33 +01:00
Sebastian Silbermann 13aae52aea Convert SimpleEventPlugin to createRoot (#28164) 2024-01-30 22:22:02 +01:00
Ricky 417188314d Update www flags (#28150)
Adds an experiment for `enableFormActions` and hardcodes
`enableCustomElementPropertySupport` on www since this is shipped.
2024-01-30 14:24:41 -05:00
Andrew Clark 178f435194 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.
2024-01-30 14:23:39 -05:00
Josh Story 554fc49f41 [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
2024-01-30 10:14:59 -08:00
Josh Story 1c958aa4ab [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
2024-01-30 10:10:19 -08:00
Sebastian Silbermann 2477384650 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.
2024-01-30 09:11:58 +01:00
Ricky 4d6c47baa3 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.
2024-01-29 14:03:39 -05:00
Ricky 4c73da8cbd Convert ReactCompositeComponent to createRoot (#28099)
Moves tests depending on legacy APIs to `ReactLegacyCompositeComponents`
and updates the rest.
2024-01-29 14:03:16 -05:00
Ricky 61df8caa3b 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.
2024-01-29 13:39:39 -05:00
Ricky cc7d421629 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
2024-01-29 12:54:32 -05:00
Sebastian Silbermann 971b62f479 Convert useFocusWithin to createRoot (#28128) 2024-01-29 17:02:49 +01:00
Sebastian Silbermann cdfaae73c4 Convert ReactDOMTextarea to createRoot (#28126)
Also removes usage of `ReactTestUtils`
2024-01-29 17:02:20 +01:00
Sebastian Silbermann 00d42ac354 Convert DOMPluginEventSystem to createRoot (#28139) 2024-01-29 09:12:20 +01:00
Sebastian Silbermann 6d2a1d0334 Convert ReactMultiChildText to createRoot (#28140) 2024-01-29 09:11:24 +01:00
Sebastian Silbermann 313e4d4129 Convert ReactDOMTextComponent to createRoot (#28141) 2024-01-29 09:11:02 +01:00
Sebastian Silbermann 1c8901f750 Convert ReactDOMSelect to createRoot (#28142) 2024-01-29 09:10:34 +01:00
Sebastian Silbermann 7aa45db6a2 Convert refs to createRoot (#28113) 2024-01-28 10:41:47 +01:00