Commit Graph
779 Commits
Author SHA1 Message Date
eps1lon 54a10b4aed Convert ReactDOMServerIntegrationLegacyContextDisabled to createRoot (#28448)
DiffTrain build for commit https://github.com/facebook/react/commit/172a7f629a972fedb9e43fbae4fad0e9b1dc7fee.
2024-02-26 20:58:57 +00:00
eps1lon e71003997f Convert ReactTestUtils to createRoot (#28446)
it'll be removed soon anyway but until then let's unblock moving legacy
APIs behind a flag.

DiffTrain build for commit https://github.com/facebook/react/commit/2314227de55b23e5819f7b96443693df16b5e911.
2024-02-26 20:58:39 +00:00
eps1lon 50338a9a68 Convert ReactServerRenderingHydration to createRoot (#28447)
DiffTrain build for commit https://github.com/facebook/react/commit/f637f6a4736a9a02ab18067ef4b1c5e033c8d6f4.
2024-02-26 20:03:42 +00:00
eps1lon d2778ef6e7 Add support for rendering BigInt (#24580)
DiffTrain build for commit https://github.com/facebook/react/commit/2f240c91ed54900adee213565cb2039e161629e9.
2024-02-26 18:23:22 +00:00
rickhanlonii 908dcaf6c5 Turn on enableRenderableContext for www (#28438)
We can land for www now

DiffTrain build for commit https://github.com/facebook/react/commit/6c3b8dbfed6f879440f484bd0bf801fac67ec684.
2024-02-26 15:13:23 +00:00
rickhanlonii 2141e10efc Make enableClientRenderFallbackOnText dynamic (#28436)
DiffTrain build for commit https://github.com/facebook/react/commit/239d06e2b8b0f2dabd6bc154e5f24d594ac5840d.
2024-02-25 18:25:42 +00:00
eps1lon 9dcf6c56bf devtools: Use context displayName for context hook name (#25954)
DiffTrain build for commit https://github.com/facebook/react/commit/aed00dacfb79d17c53218404c52b1c7aa59c4a89.
2024-02-24 10:59:03 +00:00
acdlite 108ddbefbf Delete use of source in JSX runtime (#28433)
Only remaining place it was being used was in a warning message.

DiffTrain build for commit https://github.com/facebook/react/commit/16d3f7833d25b1ea026add83dd109601b60f138e.
2024-02-23 21:56:38 +00:00
sebmarkbage 355d677cfe Remove method name prefix from warnings and errors (#28432)
This pattern is a petpeeve of mine. I don't consider this best practice
and so most don't have these prefixes. Very inconsistent.

At best this is useless and noisey that you have to parse because the
information is also in the stack trace.

At worse these are misleading because they're highlighting something
internal (like validateDOMNesting) which even suggests an internal bug.
Even the ones public to React aren't necessarily what you called because
you might be calling a wrapper around it.

That would be properly reflected in a stack trace - which can also
properly ignore list so that the first stack you see is your callsite,

Which might be like `render()` in react-testing-library rather than
`createRoot()` for example.

DiffTrain build for commit https://github.com/facebook/react/commit/d579e7748218920331252b0528850943d5e2dd31.
2024-02-23 20:21:51 +00:00
sebmarkbage 2b0bca0a1b Include server component names in the componentStack in DEV (#28415)
I'm a bit ambivalent about this one because it's not the main strategy
that I plan on pursuing. I plan on replacing most DEV-only specific
stacks like `console.error` stacks with a new take on owner stacks and
native stacks. The future owner stacks may or may not be exposed to
error boundaries in DEV but if they are they'd be a new errorInfo
property since they're owner based and not available in prod.

The use case in `console.error` mostly goes away in the future so this
PR is mainly for error boundaries. It doesn't hurt to have it in there
while I'm working on the better stacks though.

The `componentStack` property exposed to error boundaries is more like
production behavior similar to `new Error().stack` (which even in DEV
won't ever expose owner stacks because `console.createTask` doesn't
affect these). I'm not sure it's worth adding server components in DEV
(this PR) because then you have forked behavior between dev and prod.

However, since even in the future there won't be any other place to get
the *parent* stack, maybe this can be useful information even if it's
only dev. We could expose a third property on errorInfo that's DEV only
and parent stack but including server components. That doesn't seem
worth it over just having the stack differ in dev and prod.

I don't plan on adding line/column number to these particular stacks.

A follow up could be to add this to Fizz prerender too but only in DEV.

DiffTrain build for commit https://github.com/facebook/react/commit/8fb0233a845974b4b1049e54b6c25dc54d6dd173.
2024-02-23 17:09:58 +00:00
jackpope 86ff1918cc [RTR] Add usage warning behind flag (#27903)
## Summary

Moving towards deprecation of ReactTestRenderer. Log a warning on each
render so we can remove the exports in a future major version.

We can enable this flag in web RTR without disrupting RN tests by
flipping the flag in
`packages/shared/forks/ReactFeatureFlags.test-renderer.js`

## How did you test this change?

`yarn test
packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js`

DiffTrain build for commit https://github.com/facebook/react/commit/66c8346401d271588e4c400921c5dab5478fc623.
2024-02-23 16:37:57 +00:00
sammy-SC 6fb4d0dc75 [RN] Move unifiedSyncLane back to dynamic (#28430)
This surfaced a bug because it wasn't on everywhere, moving back to
dynamic while we investigate the bug

DiffTrain build for commit https://github.com/facebook/react/commit/98b8359f656ef714cc44828d7bfd2409ca16b9b3.
2024-02-23 15:35:55 +00:00
rickhanlonii 8136b16588 Add enableComponentStackLocations to ReactNativeInternalFeatureFlags libdef (#28424)
## Summary

Fixing something I accidentally broke this in
https://github.com/facebook/react/commit/25dbb3556ee9802c18f45c278abf3c33711237eb.

## How did you test this change?

Ran the following successfully:

```
$ yarn flow dom-node
```

DiffTrain build for commit https://github.com/facebook/react/commit/aaa4acb1280fcda398defb805db47a8623df6c0f.
2024-02-23 00:03:03 +00:00
yungsters f821218f87 Dynamic enableComponentStackLocations Flag for React Native (FB) (#28400)
## Summary

Changes the `enableComponentStackLocations` feature flag to be dynamic
for React Native (FB), so that it can be evaluated for compatibility
before eventually being enabled for React Native.

## How did you test this change?

I'll be importing this PR to test it.

DiffTrain build for commit https://github.com/facebook/react/commit/25dbb3556ee9802c18f45c278abf3c33711237eb.
2024-02-22 23:45:14 +00:00
rickhanlonii 6b87240cb1 Ignore /fixtures for dependabot (#28422)
We'll keep these up to date out of band, they are just for testing and
don't ship in the npm packages.

DiffTrain build for commit https://github.com/facebook/react/commit/07c2543e54f0e2ccd91908ec765683b47bc2f532.
2024-02-22 20:49:34 +00:00
rickhanlonii c97ec717a1 Make enableRefAsProp www dynamic (#28423)
Going to start rolling this out

DiffTrain build for commit https://github.com/facebook/react/commit/aaf85f3af8c30252edaab5c24975cd086937b2a4.
2024-02-22 20:40:30 +00:00
rickhanlonii d6c9dcc402 s/getRootNode/ownerDocument (#28412)
getRootNode isn't always available, use ownerDocument instead

DiffTrain build for commit https://github.com/facebook/react/commit/e4b816ba1a1ea7c1874cf3f82dd841830b71341a.
2024-02-22 19:57:40 +00:00
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