Commit Graph

762 Commits

Author SHA1 Message Date
hoxyq 9fac9d7d69 React DevTools 5.0.0 -> 5.0.1 (#28418)
Full list of changes (not a public CHANGELOG):

* feature[REMOVED][devtools]: turn off / hide location based component
filters ([hoxyq](https://github.com/hoxyq) in
[#28417](https://github.com/facebook/react/pull/28417))
* Add useSyncExternalStore and useTransition to getPrimitiveStackCache
([jamesbvaughan](https://github.com/jamesbvaughan) in
[#28399](https://github.com/facebook/react/pull/28399))
* chore[devtools]: use react-window from npm and bump
react-virtualized-auto-sizer to ^1.0.23
([hoxyq](https://github.com/hoxyq) in
[#28408](https://github.com/facebook/react/pull/28408))
* Pass ref as normal prop ([acdlite](https://github.com/acdlite) in
[#28348](https://github.com/facebook/react/pull/28348))
* Combine createElement and JSX modules
([acdlite](https://github.com/acdlite) in
[#28320](https://github.com/facebook/react/pull/28320))
* [Debug Tools] Always use includeHooksSource option
([sebmarkbage](https://github.com/sebmarkbage) in
[#28309](https://github.com/facebook/react/pull/28309))
* Revert "[Tests] Reset modules by default"
([acdlite](https://github.com/acdlite) in
[#28318](https://github.com/facebook/react/pull/28318))
* Switch <Context> to mean <Context.Provider>
([gaearon](https://github.com/gaearon) in
[#28226](https://github.com/facebook/react/pull/28226))
* [Debug Tools] Introspect Promises in use()
([sebmarkbage](https://github.com/sebmarkbage) in
[#28297](https://github.com/facebook/react/pull/28297))
* fix[devtools/useModalDismissSignal]: use getRootNode for shadow root
case support ([hoxyq](https://github.com/hoxyq) in
[#28145](https://github.com/facebook/react/pull/28145))
* fix: define IS_ACT_ENVIRONMENT global for tests with concurrent mode
and synchronous act ([hoxyq](https://github.com/hoxyq) in
[#28296](https://github.com/facebook/react/pull/28296))
* chore: gate legacy apis for react-devtools-shell
([hoxyq](https://github.com/hoxyq) in
[#28273](https://github.com/facebook/react/pull/28273))
* DevTools: Add support for use(Context)
([eps1lon](https://github.com/eps1lon) in
[#28233](https://github.com/facebook/react/pull/28233))
* Remove __self and __source location from elements
([sebmarkbage](https://github.com/sebmarkbage) in
[#28265](https://github.com/facebook/react/pull/28265))
* chore: use versioned render in inspectedElement test
([hoxyq](https://github.com/hoxyq) in
[#28246](https://github.com/facebook/react/pull/28246))
* chore: use versioned render in TimelineProfiler test and gate some for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28218](https://github.com/facebook/react/pull/28218))
* [Tests] Reset modules by default
([rickhanlonii](https://github.com/rickhanlonii) in
[#28254](https://github.com/facebook/react/pull/28254))
* chore: use versioned render in preprocessData test and gate some for …
([hoxyq](https://github.com/hoxyq) in
[#28219](https://github.com/facebook/react/pull/28219))
* chore: use versioned render in storeStressSync test and gate them for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28216](https://github.com/facebook/react/pull/28216))
* Patch devtools before running useMemo function in strict mode
([gsathya](https://github.com/gsathya) in
[#28249](https://github.com/facebook/react/pull/28249))
* chore: use versioned render in storeComponentFilters test
([hoxyq](https://github.com/hoxyq) in
[#28241](https://github.com/facebook/react/pull/28241))
* chore: use versioned render in profilerContext test
([hoxyq](https://github.com/hoxyq) in
[#28243](https://github.com/facebook/react/pull/28243))
* chore: use versioned render in profilingCommitTreeBuilder test and
gate some for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28236](https://github.com/facebook/react/pull/28236))
* chore: use versioned render in profilingHostRoot test and gate some
for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28237](https://github.com/facebook/react/pull/28237))
* chore: use versioned render in profilingCache test
([hoxyq](https://github.com/hoxyq) in
[#28242](https://github.com/facebook/react/pull/28242))
* chore: use versioned render in ownersListContext test
([hoxyq](https://github.com/hoxyq) in
[#28240](https://github.com/facebook/react/pull/28240))
* chore: use versioned render in editing test
([hoxyq](https://github.com/hoxyq) in
[#28239](https://github.com/facebook/react/pull/28239))
* chore: use versioned render in treeContext test
([hoxyq](https://github.com/hoxyq) in
[#28245](https://github.com/facebook/react/pull/28245))
* chore: use versioned render in store test
([hoxyq](https://github.com/hoxyq) in
[#28244](https://github.com/facebook/react/pull/28244))
* chore: use versioned render in profilerStore test
([hoxyq](https://github.com/hoxyq) in
[#28238](https://github.com/facebook/react/pull/28238))
* chore: use versioned render in profilingCharts test
([hoxyq](https://github.com/hoxyq) in
[#28235](https://github.com/facebook/react/pull/28235))
* chore: use versioned render in profilerChangeDescriptions test
([hoxyq](https://github.com/hoxyq) in
[#28221](https://github.com/facebook/react/pull/28221))
* chore: use versioned render in storeOwners test
([hoxyq](https://github.com/hoxyq) in
[#28215](https://github.com/facebook/react/pull/28215))
* chore: use versioned render in componentStacks test
([hoxyq](https://github.com/hoxyq) in
[#28214](https://github.com/facebook/react/pull/28214))
* chore: use versioned render in console test
([hoxyq](https://github.com/hoxyq) in
[#28213](https://github.com/facebook/react/pull/28213))
* chore: use versioned render in useEditableValue test
([hoxyq](https://github.com/hoxyq) in
[#28212](https://github.com/facebook/react/pull/28212))
* chore: use versioned render in FastRefreshDevToolsIntegration test
([hoxyq](https://github.com/hoxyq) in
[#28211](https://github.com/facebook/react/pull/28211))
* chore: add versioned render implementation for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[#28210](https://github.com/facebook/react/pull/28210))
* chore: add single versioned implementation of act for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[#28186](https://github.com/facebook/react/pull/28186))
* DevTools: Add support for useFormState
([eps1lon](https://github.com/eps1lon) in
[#28232](https://github.com/facebook/react/pull/28232))
* DevTools: Add support for useOptimistic Hook
([eps1lon](https://github.com/eps1lon) in
[#27982](https://github.com/facebook/react/pull/27982))
* Add stable React.act export ([acdlite](https://github.com/acdlite) in
[#28160](https://github.com/facebook/react/pull/28160))
* [flow] upgrade to 0.225.1 ([kassens](https://github.com/kassens) in
[#27871](https://github.com/facebook/react/pull/27871))
* fix[devtools/e2e]: add fallback for act in integration tests
([hoxyq](https://github.com/hoxyq) in
[#27842](https://github.com/facebook/react/pull/27842))
* Add stable concurrent option to react-test-renderer
([jackpope](https://github.com/jackpope) in
[#27804](https://github.com/facebook/react/pull/27804))
* Update act references in tests ([gnoff](https://github.com/gnoff) in
[#27805](https://github.com/facebook/react/pull/27805))
* Flow: make more objects exact ([kassens](https://github.com/kassens)
in [#27790](https://github.com/facebook/react/pull/27790))

DiffTrain build for commit https://github.com/facebook/react/commit/288cf747c96cea278a6ddce126ce7a0484678afd.
2024-02-22 19:50:54 +00:00
hoxyq a152975172 fix[devtools]: fixed Tree indentation logic after updating react-windows (#28421)
Forward-fixing the indentation after landing
https://github.com/facebook/react/pull/28408. Could potentially be
related to `ref` changes in `react`, but haven't validated yet.

Haven't occured while testing the previous PR, but reproduced while
testing the https://github.com/facebook/react/pull/28418, for which I've
rebuilt all dependencies, including `react`.

This change basically removes the props passing from original parent,
`rest` should include only `ref`:
https://github.com/bvaughn/react-window/blob/efad3d8909753fd74aad7c47dc902b26f0919651/src/createListComponent.js#L382

DiffTrain build for commit https://github.com/facebook/react/commit/d54b4cf303143b459c3caae54d14ae926a8ee09a.
2024-02-22 19:23:04 +00:00
hoxyq c730c69f19 feature[REMOVED][devtools]: turn off / hide location based component filters (#28417)
Following https://github.com/facebook/react/pull/28265, this should
disable location-based component filters.

```
// Following __debugSource removal from Fiber, the new approach for finding the source location
// of a component, represented by the Fiber, is based on lazily generating and parsing component stack frames
// To find the original location, React DevTools will perform symbolication, source maps are required for that.
// In order to start filtering Fibers, we need to find location for all of them, which can't be done lazily.
// Eager symbolication can become quite expensive for large applications.
```

I am planning to publish a patch version of RDT soon, so I think its
better to remove this feature, instead of shipping it in a broken state.

The reason for filtering out these filters is a potential cases, where
we load filters from the backend (like in RN, where we storing some
settings on device), or these filters can be stored in user land
(`window.__REACT_DEVTOOLS_COMPONENT_FILTERS__`).

Explicitly tested the case when:
1. Load current RDT extension, add location-based component filter
2. Reload the page and observe that previously created component filter
is preserved
3. Re-load RDT extension with these changes, observe there is no
previously created component filter and user can't create a new
location-based filter
4. Reload RDT extension without these changes, no location-based filters
saved, user can create location-based filters

DiffTrain build for commit https://github.com/facebook/react/commit/d4cac3f96c01b4222f917a2e5a8ce85754f706f8.
2024-02-22 17:04:09 +00:00
hoxyq 00a0b1ce2e Add useSyncExternalStore and useTransition to getPrimitiveStackCache (#28399)
<!--
  Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.

Before submitting a pull request, please make sure the following is
done:

1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
  2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->

This solves the problem of the devtools extension failing to parse hook
names for components that make use of `useSyncExternalStore` or
`useTransition`.

See #27889

## 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.
-->

I tested this against my own codebases and against the example repro
project that I linked in #27889.

To test, I opened up the Components tab of the dev tools extension,
selected a component with hooks that make use of `useSyncExternalStore`
or `useTransition`, clicked the "parse hook names" magic wand button,
and observed that it now succeeds.

DiffTrain build for commit https://github.com/facebook/react/commit/47beb96ccf1085fe048c4d79d1f762566166d94e.
2024-02-22 11:49:27 +00:00
hoxyq 1db66df24a chore[devtools]: use react-window from npm and bump react-virtualized-auto-sizer to ^1.0.23 (#28408)
1. Bumps `react-virtualized-auto-sizer` to 1.0.23, which has a fix for
cases with multiple realms -
https://github.com/bvaughn/react-virtualized-auto-sizer/pull/82
2. Removes `react-window` from react-devtools-shared/src/node_modules,
now listed as dependency in `package.json` and bumped to 1.8.10

Tested:
- Chrome extension
- Standalone shell with RN

DiffTrain build for commit https://github.com/facebook/react/commit/404ed926588ec1cb7e9524d4dbb75b7297130adc.
2024-02-22 11:37:07 +00:00
eps1lon 4683bd9c21 Add smoke test for flight fixture (#28350)
DiffTrain build for commit https://github.com/facebook/react/commit/81d2a51a97ca8ea7cfbce885ecab070a668732ab.
2024-02-21 22:52:41 +00:00
jackpope ee7a0aa9b0 Remove RTR from StrictEffectsMode-test (#28387)
## Summary

Cleaning up internal usage of ReactTestRenderer

## How did you test this change?

`yarn test
packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js`

DiffTrain build for commit https://github.com/facebook/react/commit/59fe6c3ac1d52e4e568be52b908905b8898a4777.
2024-02-21 20:22:31 +00:00
sebmarkbage d77e880da8 [Flight] Prefix Replayed Console Logs with a Badge (#28403)
Builds on top of #28384.

This prefixes each log with a badge similar to how we badge built-ins
like "ForwardRef" and "Memo" in the React DevTools. The idea is that we
can add such badges in DevTools for Server Components too to carry on
the consistency.

This puts the "environment" name in the badge which defaults to
"Server". So you know which source it is coming from.

We try to use the same styling as the React DevTools. We use light-dark
mode where available to support the two different color styles, but if
it's not available I use a fixed background so that it's always readable
even in dark mode.

In Terminals, instead of hard coding colors that might not look good
with some themes, I use the ANSI color code to flip
background/foreground colors in that case.

In earlier commits I had it on the end of the line similar to the
DevTools badges but for multiline I found it better to prefix it. We
could try various options tough.

In most cases we can use both ANSI and the `%c` CSS color specifier,
because node will only use ANSI and hide the other. Chrome supports both
but the color overrides ANSI if it comes later (and Chrome doesn't
support color inverting anyway). Safari/Firefox prints the ANSI, so it
can only use CSS colors.

Therefore in browser builds I exclude ANSI.

On the server I support both so if you use Chrome inspector on the
server, you get nice colors on both terminal and in the inspector.

Since Bun uses WebKit inspector and it prints the ANSI we can't safely
emit both there. However, we also can't emit just the color specifier
because then it prints in the terminal.
https://github.com/oven-sh/bun/issues/9021 So we just use a plain string
prefix for now with a bracket until that's fixed.

Screen shots:

<img width="758" alt="Screenshot 2024-02-21 at 12 56 02 AM"
src="https://github.com/facebook/react/assets/63648/4f887ffe-fffe-4402-bf2a-b7890986d60c">
<img width="759" alt="Screenshot 2024-02-21 at 12 56 24 AM"
src="https://github.com/facebook/react/assets/63648/f32d432f-f738-4872-a700-ea0a78e6c745">
<img width="514" alt="Screenshot 2024-02-21 at 12 57 10 AM"
src="https://github.com/facebook/react/assets/63648/205d2e82-75b7-4e2b-9d9c-aa9e2cbedf39">
<img width="489" alt="Screenshot 2024-02-21 at 12 57 34 AM"
src="https://github.com/facebook/react/assets/63648/ea52d1e4-b9fa-431d-ae9e-ccb87631f399">
<img width="516" alt="Screenshot 2024-02-21 at 12 58 23 AM"
src="https://github.com/facebook/react/assets/63648/52b50fac-bec0-471d-a457-1a10d8df9172">
<img width="956" alt="Screenshot 2024-02-21 at 12 58 56 AM"
src="https://github.com/facebook/react/assets/63648/0096ed61-5eff-4aa9-8a8a-2204e754bd1f">

DiffTrain build for commit https://github.com/facebook/react/commit/c0274063f0d625d6e17e82f3436f4a0b78b7e58f.
2024-02-21 20:03:46 +00:00
sebmarkbage 1e2c8001c7 [Flight] Instrument the Console in the RSC Environment and Replay Logs on the Client (#28384)
When developing in an RSC environment, you should be able to work in a
single environment as if it was a unified environment. With thrown
errors we already serialize them and then rethrow them on the client.

Since by default we log them via onError both in Flight and Fizz, you
can get the same log in the RSC runtime, the SSR runtime and on the
client.

With console logs made in SSR renders, you typically replay the same
code during hydration on the client. So for example warnings already
show up both in the SSR logs and on the client (although not guaranteed
to be the same). You could just spend your time in the client and you'd
be fine.

Previously, RSC logs would not be replayed because they don't hydrate.
So it's easy to miss warnings for example.

With this approach, we replay RSC logs both during SSR so they end up in
the SSR logs and on the client. That way you can just stay in the
browser window during normal development cycles. You shouldn't have to
care if your component is a server or client component when working on
logical things or iterating on a product.

With this change, you probably should mostly ignore the Flight log
stream and just look at the client or maybe the SSR one. Unless you're
digging into something specific. In particular if you just naively run
both Flight and Fizz in the same terminal you get duplicates. I like to
run out fixtures `yarn dev:region` and `yarn dev:global` in two separate
terminals.

Console logs may contain complex objects which can be inspected. Ideally
a DevTools inspector could reach into the RSC server and remotely
inspect objects using the remote inspection protocol. That way complex
objects can be loaded on demand as you expand into them. However, that
is a complex environment to set up and the server might not even be
alive anymore by the time you inspect the objects. Therefore, I do a
best effort to serialize the objects using the RSC protocol but limit
the depth that can be rendered.

This feature is only own in dev mode since it can be expensive.

In a follow up, I'll give the logs a special styling treatment to
clearly differentiate them from logs coming from the client. As well as
deal with stacks.

DiffTrain build for commit https://github.com/facebook/react/commit/9a5b6bd84ffa69bfd8b2859ce23e56d17daa8c40.
2024-02-21 19:52:37 +00:00
noahlemen 73e64de370 remove RTR from ReactCacheOld-test (#28409)
## Summary

swaps `react-test-renderer` for `react-noop-rendererer` in
ReactCacheOld-test

## How did you test this change?

`yarn test-www ReactCacheOld`

DiffTrain build for commit https://github.com/facebook/react/commit/41b3c31bcbe9f238697b4c79b39017916e0f131c.
2024-02-21 18:37:20 +00:00
acdlite 35138244c6 Convert string ref props to callback props (#28398)
When enableRefAsProp is on, we should always use the props as the source
of truth for refs. Not a field on the fiber.

In the case of string refs, this presents a problem, because string refs
are not passed around internally as strings; they are converted to
callback refs. The ref used by the reconciler is not the same as the one
the user provided.

But since this is a deprecated feature anyway, what we can do is clone
the props object and replace it with the internal callback ref. Then we
can continue to use the props object as the source of truth.

This means the internal callback ref will leak into userspace. The
receiving component will receive a callback ref even though the parent
passed a string. Which is weird, but again, this is a deprecated
feature, and we're only leaving it around behind a flag so that Meta can
keep using string refs temporarily while they finish migrating their
codebase.

DiffTrain build for commit https://github.com/facebook/react/commit/dc30644ca77e52a2760e81fbdbcfbd2f2fd4979c.
2024-02-21 16:46:30 +00:00
gaearon bb2b69ad43 refactor: remove dead types of fiber (#28405)
The properties `firstEffect` and `lastEffect` of the Fiber are currently
not being used and are considered to be dead code, and can be removed.

DiffTrain build for commit https://github.com/facebook/react/commit/ddd736d2589c972e1ac75402f2e2e833e97ad61a.
2024-02-21 11:22:00 +00:00
gaearon 81206cb14a Remove JSX propTypes validation (#28328)
This removes the remaining `propTypes` validation calls, making
declaring `propTypes` a no-op. In other words, React itself will no
longer validate the `propTypes` that you declare on your components.

In general, our recommendation is to use static type checking (e.g.
TypeScript). If you'd like to still run propTypes checks, you can do so
manually, same as you'd do outside React:

```js
import checkPropTypes from 'prop-types/checkPropTypes';

function Button(props) {
  checkPropTypes(Button.propTypes, prop, 'prop', Button.name)
  // ...
}
```

This could be automated as a Babel plugin if you want to keep these
checks implicit. (We will not be providing such a plugin, but someone in
community might be interested in building or maintaining one.)

DiffTrain build for commit https://github.com/facebook/react/commit/353ecd05160a318a3f75260ee7906fd12e05cb9d.
2024-02-21 11:20:31 +00:00
sebmarkbage c825387e38 Capitalize the default Flight environment (#28402)
It's cleaner and more in line with how we style other badges like "Memo"
and "ForwardRef" in DevTools.

DiffTrain build for commit https://github.com/facebook/react/commit/4ea424e63d1a74ce57ef675b64a8c4eabfdb2fdc.
2024-02-21 03:34:56 +00:00
jackpope 1a565fb898 Remove RTR from ReactCreateRef-test (#28386)
## Summary

Cleaning up internal usage of ReactTestRenderer

## How did you test this change?

`yarn test packages/react/src/__tests__/ReactCreateRef-test.js`

DiffTrain build for commit https://github.com/facebook/react/commit/3b260007ed28593ca4ad0505591387dd57c57b0d.
2024-02-20 22:54:43 +00:00
jackpope e162f019ef Remove RTR usage from useSubscription-test (#28388)
## Summary

Cleaning up internal usage of ReactTestRenderer

## How did you test this change?

`yarn test
packages/use-subscription/src/__tests__/useSubscription-test.js`

DiffTrain build for commit https://github.com/facebook/react/commit/0778f61321ebb235b49e4630e43e734a9badbd5c.
2024-02-20 22:54:15 +00:00
eps1lon 7fce24f8a4 Remove unused ReactTestUtils from ReactDOMServerIntegration tests (#28379)
DiffTrain build for commit https://github.com/facebook/react/commit/cefc1c66c179e5cca255f1ff53610a0ed9f8e710.
2024-02-20 21:54:09 +00:00
eps1lon 793f6c0667 Bump actions/checkout (#28383)
DiffTrain build for commit https://github.com/facebook/react/commit/51c9146072395b13ab56834393a1c30f3ddedec8.
2024-02-20 21:51:22 +00:00
jackpope 3670bf7ec7 Remove RTR from ReactSuspense-test (#28390)
## Summary

Cleaning up internal usage of ReactTestRenderer

## How did you test this change?

`yarn test
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js`

DiffTrain build for commit https://github.com/facebook/react/commit/90a0ae101571f58781225dd0dc1948b0a15ea9e4.
2024-02-20 20:45:12 +00:00
rickhanlonii ce600dc084 refactor: remove dead code of fiber (#28389)
The `nextEffect` property of the `fiber` is currently not being used and
has become dead code. It can be safely removed.

DiffTrain build for commit https://github.com/facebook/react/commit/49441e342f0c5252eb24bb352cf76ac59aef353c.
2024-02-20 19:35:56 +00:00
sebmarkbage dc9a0aa279 Rename default FlightClientConfigs to FlightClientStreamConfig (#28382)
Since this is more about specifically the streaming protocol and I'll
add other dimensions that don't map 1:1.

E.g. some configs need to be the same across all servers.

DiffTrain build for commit https://github.com/facebook/react/commit/8f012266dc127d7bd36e28c22e1ad77ec0ae95fa.
2024-02-20 19:27:52 +00:00
acdlite c25dcdbe80 Pass ref as normal prop (#28348)
Depends on:

- #28317
- #28320

---

Changes the behavior of the JSX runtime to pass through `ref` as a
normal prop, rather than plucking it from the props object and storing
on the element.

This is a breaking change since it changes the type of the receiving
component. However, most code is unaffected since it's unlikely that a
component would have attempted to access a `ref` prop, since it was not
possible to get a reference to one.

`forwardRef` _will_ still pluck `ref` from the props object, though,
since it's extremely common for users to spread the props object onto
the inner component and pass `ref` as a differently named prop. This is
for maximum compatibility with existing code — the real impact of this
change is that `forwardRef` is no longer required.

Currently, refs are resolved during child reconciliation and stored on
the fiber. As a result of this change, we can move ref resolution to
happen only much later, and only for components that actually use them.
Then we can remove the `ref` field from the Fiber type. I have not yet
done that in this step, though.

DiffTrain build for commit https://github.com/facebook/react/commit/fa2f82addc7c817892c482792f56a35277e8b75a.
2024-02-20 19:22:36 +00:00
eps1lon 5a8f5c841b Remove ReactTestUtils from ReactDOM-test (#28377)
DiffTrain build for commit https://github.com/facebook/react/commit/7b196be09167f8fe9091168dab1769a552263065.
2024-02-20 15:58:22 +00:00
eps1lon 40ebd6c2bf Remove ReactTestUtils from ReactDOMComponent (#28334)
DiffTrain build for commit https://github.com/facebook/react/commit/1deda7690fc95d873b14cbcb0ee6c8f1dd1395a3.
2024-02-20 15:57:20 +00:00
eps1lon 176090cdc0 Remove ReactTestUtils from ReactUpdates (#28378)
DiffTrain build for commit https://github.com/facebook/react/commit/48ca0e82985a1f0cdd2787a281166a59af4b88d0.
2024-02-20 15:56:48 +00:00
eps1lon 949b15ad0a Remove ReactTestUtils from ReactComponentLifeCycle (#28376)
DiffTrain build for commit https://github.com/facebook/react/commit/3c9560b29e77f11b2dc39ccb05a92361e9af2a1d.
2024-02-20 15:56:43 +00:00
eps1lon 9ba28bb898 Remove ReactTestUtils from ReactJSXTransformIntegration (#28338)
DiffTrain build for commit https://github.com/facebook/react/commit/e68431c89fe7ed36f7eac4f607a9d4836d3788fd.
2024-02-20 15:55:27 +00:00
eps1lon 5cc522e200 Remove usage of ReactTestUtils from ReactFunctionComponent (#28331)
DiffTrain build for commit https://github.com/facebook/react/commit/7ab84fb1168d14b895fc9569b6b6899a10bfdc78.
2024-02-20 15:55:04 +00:00
eps1lon dd900552ff Remove ReactTestUtils from refs-test (#28336)
DiffTrain build for commit https://github.com/facebook/react/commit/b559f5fefed48a7e95afe3bece9e625d4b4b82a2.
2024-02-20 15:54:48 +00:00
acdlite 2579855f59 Combine createElement and JSX modules (#28320)
Depends on:

- #28317

---

There's a ton of overlap between the createElement implementation and
the JSX implementation, so I combined them into a single module.

In the actual build output, the shared code between JSX and
createElement will get duplicated anyway, because react/jsx-runtime and
react (where createElement lives) are separate, flat build artifacts.

So this is more about code organization — with a few key exceptions, the
implementations of createElement and jsx are highly coupled.

DiffTrain build for commit https://github.com/facebook/react/commit/5fb2c93f3924ba980444da5698f60651b5ef0689.
2024-02-20 03:49:48 +00:00
acdlite 163b2f081b Combine ReactJSXElementValidator with main module (#28317)
There are too many layers to the JSX runtime implementation. I think
basically everything should be implemented in a single file, so that's
what I'm going to do.

As a first step, this deletes ReactJSXElementValidator and moves all the
code into ReactJSXElement. I can already see how this will help us
remove more indirections in the future.

Next I'm going to do start moving the `createElement` runtime into this
module as well, since there's a lot of duplicated code.

DiffTrain build for commit https://github.com/facebook/react/commit/ec160f32c28ccab798c73ecccbb36ce121e1640e.
2024-02-20 03:19:17 +00:00
acdlite b125fcb132 Move all markRef calls into begin phase (#28375)
Certain fiber types may have a ref attached to them. The main ones are
HostComponent and ClassComponent. During the render phase, we check if a
ref was passed to it, and if so, we schedule a Ref effect: `markRef`.

Currently, we're not consistent about whether we call `markRef` in the
begin phase or the complete phase. For some fiber types, I found that
`markRef` was called in both phases, causing redundant work.

After some investigation, I don't believe it's necessary to call
`markRef` in both the begin phase and the complete phase, as long as you
don't bail out before calling `markRef`.

I though that maybe it had to do with the
`attemptEarlyBailoutIfNoScheduledUpdates` branch, which is a fast path
that skips the regular begin phase if no new props, state, or context
were passed. But if the props haven't changed (referentially — the
`memo` and `shouldComponentUpdate` checks happen later), then it follows
that the ref couldn't have changed either. This is true even in the old
`createElement` runtime where `ref` is stored on the element instead of
as a prop, because there's no way to pass a new ref to an element
without also passing new props. You might argue this is a leaky
assumption, but since we're shifting ref to be just a regular prop
anyway, I think it's the correct way to think about it going forward.

I think the pattern of calling `markRef` in the complete phase may have
been left over from an earlier iteration of the implementation before
the bailout logic was structured like it is today.

So, I removed all the `markRef` calls from the complete phase. In the
case of ScopeComponent, which had no corresponding call in the begin
phase, I added one.

We already had a test that asserted that a ref is reattached even if the
component bails out, but I added some new ones to be extra safe.

The reason I'm changing this this is because I'm working on a different
change to move the ref handling logic in `coerceRef` to happen in render
phase of the component that accepts the ref, instead of during the
parent's reconciliation.

DiffTrain build for commit https://github.com/facebook/react/commit/c820097716c3d9765bf85bf58202a4975d99e450.
2024-02-20 02:11:18 +00:00
sebmarkbage 469809a4b4 [Flight] Better error message if you pass a function as a child to a client component (#28367)
Similar to #28362 but if you pass it to a client component.

DiffTrain build for commit https://github.com/facebook/react/commit/2e84e1629924e6cb278638305fa92040f6ef6eb5.
2024-02-19 17:41:18 +00:00
sebmarkbage 9afcb6848f Encode better error messages when part of the context is a client reference (#28355)
Alternative to #28354.

If a client reference is one of the props being describes as part of
another error, we call toString on it, which errors.

We should error explicitly when a Symbol prop is extracted.

However, pragmatically I added the toString symbol tag even though we
don't know what the real tostring will be but we also lie about the
typeof.

We can however in addition to this give it a different description
because describing this property as an object isn't quite right.

We probably could extract the export name but that's kind of renderer
specific and I just added this shared module to Fizz which doesn't have
that which is unfortunate an consequence.

For default exports we don't have a good name of what the alias was in
the receiver. Could maybe call it "default" but for now I just call it
"client".

DiffTrain build for commit https://github.com/facebook/react/commit/c323f8290c2336713b62c69322bb30ed63234c24.
2024-02-19 16:55:04 +00:00
sebmarkbage ff7932da18 [Flight] Warn if this argument is passed to .bind of a Server Reference (#28380)
This won't ever be serialized and is likely just a mistake.

This should be covered by the "use server" compiler since it ensures
that something that accepts a "this" won't be allowed to compile and if
it doesn't accept it, TypeScript should ideally forbid it to be passed.

So maybe this is unnecessary.

DiffTrain build for commit https://github.com/facebook/react/commit/65a0e2b25ec4642f83c32d7599b5252c3955a60b.
2024-02-19 16:54:47 +00:00
sebmarkbage 953baa509d [Flight] Allow a Server Reference to be registered twice (#28343)
It's possible for the same function instance to appear more than once in
the same graph or even the same file.

Currently this errors on trying to reconfigure the property but it
really doesn't matter which one wins. First or last.

Regardless there will be an entry point generated that can get them.

DiffTrain build for commit https://github.com/facebook/react/commit/9444c51c7e44936c24e1f44db905cfd45c51cff3.
2024-02-19 16:54:15 +00:00
eps1lon 93c031d67e Improve stack trace when gated test fails (#28374)
DiffTrain build for commit https://github.com/facebook/react/commit/59831c98cffe0edf706238b067928e7cf54d1065.
2024-02-18 17:20:42 +00:00
sebmarkbage 9452c20ca0 Include the function name for context on invalid function child (#28362)
Also warn for symbols.

It's weird because for objects we throw a hard error but functions we do
a dev only check. Mainly because we have an object branch anyway.

In the object branch we have some built-ins that have bad errors like
forwardRef and memo but since they're going to become functions later, I
didn't bother updating those. Once they're functions those names will be
part of this.

DiffTrain build for commit https://github.com/facebook/react/commit/c1fd2a91b1042c137d750be85e5998f699a54d2a.
2024-02-17 21:46:43 +00:00
eps1lon c2e732f814 Fix crash running yarn flags --sort flag (#28344)
DiffTrain build for commit https://github.com/facebook/react/commit/fef30c2e0403e0c6986904be89fcd01e665866ee.
2024-02-17 14:33:14 +00:00
eps1lon a5c1dde54d Annotate legacy mode test in ReactDOMSingletonComponents (#28339)
These are mainly regression tests for legacy root.

DiffTrain build for commit https://github.com/facebook/react/commit/62a9c7db185b0852fccd0e48797a3de05520f120.
2024-02-17 14:33:04 +00:00
sebmarkbage aaf4f7aeaf Consume the RSC stream twice in the Flight fixture (#28353)
We have an unresolved conflict where the Flight client wants to execute
inside Fizz to emit side-effects like preloads (which can be early) into
that stream. However, the FormState API requires the state to be passed
at the root, so if you're getting that through the RSC payload it's a
Catch 22.

#27314 used a hack to mutate the form state array to fill it in later,
but that doesn't actually work because it's not always an array. It's
sometimes null like if there wasn't a POST. This lead to a bunch of
hydration errors - which doesn't have the best error message for this
case neither. It probably should error with something that specifies
that it's form state.

This fixes it by teeing the stream into two streams and consuming it
with two Flight clients. One to read the form state and one to emit
side-effects and read the root.

DiffTrain build for commit https://github.com/facebook/react/commit/6a44f352ecdfa93949cade1d2e74755e7d7e9aaa.
2024-02-16 23:28:52 +00:00
jackpope 32643b0eb3 Add useModernStrictMode as dynamic flag on www (#28346)
## Summary

Preparing modern strict mode rollout with dynamic feature flag

## How did you test this change?

![Screenshot 2024-02-15 at 10 09
49 AM](https://github.com/facebook/react/assets/8965173/9e90efc2-3578-4e63-ae2c-63d4a4e194b3)

DiffTrain build for commit https://github.com/facebook/react/commit/ef72271c2d1234c9d1e1358f8083021089a50faa.
2024-02-16 20:22:44 +00:00
gnoff 2a45e92f33 stash the component stack on the thrown value and reuse (#25790)
ErrorBoundaries are currently not fully composable. The reason is if you
decide your boundary cannot handle a particular error and rethrow it to
higher boundary the React runtime does not understand that this throw is
a forward and it recreates the component stack from the Boundary
position. This loses fidelity and is especially bad if the boundary is
limited it what it handles and high up in the component tree.

This implementation uses a WeakMap to store component stacks for values
that are objects. If an error is rethrown from an ErrorBoundary the
stack will be pulled from the map if it exists. This doesn't work for
thrown primitives but this is uncommon and stashing the stack on the
primitive also wouldn't work

DiffTrain build for commit https://github.com/facebook/react/commit/a9cc32511a12c261ee719e5383818182800d6af4.
2024-02-16 04:48:19 +00:00
sebmarkbage d54257a11a Downgrade pmmmwh/react-refresh-webpack-plugin in the Flight fixture (#28352)
The newer version triggers an error due to require() not being compiled.

This was upgraded in #27328. I'm not sure why that was needed. Maybe it
was just because it was allowed by the caret and something else upgraded
but I haven't been able to make it work with the newer version. So I'll
just pin it.

DiffTrain build for commit https://github.com/facebook/react/commit/2ba1b7856975fb350ff1cabe575e6364cc6e8465.
2024-02-16 03:29:07 +00:00
gaearon 1fd3b1a8df Remove non-JSX propTypes checks (#28326)
Removes all `propTypes` validation called from outside the JSX
factories. Haven't touched JSX.

Tests that verify related behavior are stripped down to the
non-`propTypes` logic.

DiffTrain build for commit https://github.com/facebook/react/commit/fea900e45447214ddd6ef69076ab7e38433b5ffd.
2024-02-16 00:40:01 +00:00
sebmarkbage c122bf0cd1 [Flight] Fix reference param type in registerServerReference (#27688)
The `reference` that is passed into `registerServerReference` can be a
plain function. It does not need to have the three additonal properties
of a `ServerRefeference`. In fact, adding these properties (plus `bind`)
is precisely what `registerServerReference` does.

DiffTrain build for commit https://github.com/facebook/react/commit/92686722cae09ebc3dd5f4aec61b0d067fba1203.
2024-02-15 21:14:15 +00:00
eps1lon 998bd0a10c Remove usage of ReactTestUtils from ReactContextValidator (#28329)
DiffTrain build for commit https://github.com/facebook/react/commit/0745e6bee9edb9842dfa7efa6f9835e5be6d8b98.
2024-02-15 18:19:28 +00:00
eps1lon 90b879b83e Remove ReactTestUtils from ReactIdentity (#28332)
DiffTrain build for commit https://github.com/facebook/react/commit/710d5137e27db578dfec723b2c006821a1a61973.
2024-02-15 18:18:52 +00:00
sebmarkbage fb9b7a4e30 [Fizz] Align recoverable error serialization in dev mode (#28340)
Same as #28327 but for Fizz.

One thing that's weird about this recoverable error is that we don't
send the regular stack for it, just the component stack it seems. This
is missing some potential information and if we move toward integrated
since stacks it would be one thing.

DiffTrain build for commit https://github.com/facebook/react/commit/2e470a788e359e34feeadb422daaff046baf66cc.
2024-02-15 01:20:32 +00:00
sebmarkbage cf544ed2e5 [Flight] Improve error message when it's not a real Error object (#28327)
Also deals with symbols. Alternative to #28312.

We currently always normalize rejections or thrown values into `Error`
objects. Partly because in prod it'll be an error object and you
shouldn't fork behavior on knowing the value outside a digest. We might
want to even make the message always opaque to avoid being tempted and
then discover in prod that it doesn't work.

However, we do include the message in DEV.

If this is a non-Error object we don't know what the properties mean.
Ofc, we don't want to include too much information in the rendered
string, so we use the general `describeObjectForErrorMessage` helper.
Unfortunately it's pretty conservative about emitting values so it's
likely to exclude any embedded string atm. Could potentially expand it a
bit.

We could in theory try to serialize as much as possible and re-throw the
actual object to allow for inspection to be expanded inside devtools
which is what I plan on for consoles, but since we're normalizing to an
Error this is in conflict with that approach.

DiffTrain build for commit https://github.com/facebook/react/commit/a7144f297c1c6fe457ca30ce6a211ab59feac11e.
2024-02-14 23:26:43 +00:00