Commit Graph

800 Commits

Author SHA1 Message Date
hoxyq 33cc5224d4 refactor[devtools]: lazily define source for fiber based on component stacks (#28351)
`_debugSource` was removed in
https://github.com/facebook/react/pull/28265.

This PR migrates DevTools to define `source` for Fiber based on
component stacks. This will be done lazily for inspected elements, once
user clicks on the element in the tree.

`DevToolsComponentStackFrame.js` was just copy-pasted from the
implementation in `ReactComponentStackFrame`.

Symbolication part is done in
https://github.com/facebook/react/pull/28471 and stacked on this commit.

DiffTrain build for commit https://github.com/facebook/react/commit/61bd00498d2a6e23885bac42f3aeb0e02cadb8eb.
2024-03-05 12:15:20 +00:00
hoxyq 35a4e339cf fix[devtools/tree/element]: onClick -> onMouseDown to handle first click correctly (#28486)
There is a weird behaviour in all shells of RDT: when user opens
`Components` tab and scrolls down a tree (without any prior click or
focus event), and then clicks on some element, the `click` event will
not be fired. Because `click` event hasn't been fired, the `focus` event
is fired for the whole list and we pre-select the first (root) element
in the tree:

https://github.com/facebook/react/blob/034130c02ffb47b0026059b57d17e9b080976ff3/packages/react-devtools-shared/src/devtools/views/Components/Tree.js#L217-L226

Check the demo (before) what is happening. I don't know exactly why
`click` event is not fired there, but it only happens:
1. For elements, which were not previously rendered (for virtualization
purposes).
2. When HTML-element (div), which represents the container for the tree
was not focused previously.

Unlike the `click` event, the `mousedown` event is fired consistently.

### Before

https://github.com/facebook/react/assets/28902667/9f3ad75d-55d0-4c99-b2d0-ead63a120ea0

### After

https://github.com/facebook/react/assets/28902667/e34816be-644c-444c-8e32-562a79494e44

Tested that it works in all shells, including the select / deselect
features (with `metaKey` param in event).

DiffTrain build for commit https://github.com/facebook/react/commit/aa4eae6b99a6081afabf180d02fa0a8b0cb1b3ab.
2024-03-05 11:45:41 +00:00
gnoff ed524df4a3 [Test] Update flushSync tests to use react-dom (#28490)
Updates the `flushSync` tests to use react-dom instead of ReactNoop.
flushSync is primarily a react-dom API and asserting the implementation
of ReactNoop is not really ideal especially since we are going to be
refactoring flushSync soon to not be implemented in the reconciler
internals.

ReactNoop still have a flushSync api and it can still be used in other
tests that are primarily about testing other functionlity and use
ReactNoop as the renderer.

DiffTrain build for commit https://github.com/facebook/react/commit/0ae2b13412e0e4cf10a799ec645035213834556c.
2024-03-05 05:45:08 +00:00
gnoff 73fd2ce60f [Flight][Fizz][Fiber] Chain HostDispatcher implementations (#28488)
The idea here is that host dispatchers are not bound to renders so we
need to be able to dispatch to them at any time. This updates the
implementation to chain these dispatchers so that each renderer can
respond to the dispatch. Semantically we don't always want every
renderer to do this for instance if Fizz handles a float method we don't
want Fiber to as well so each dispatcher implementation can decide if it
makes sense to forward the call or not. For float methods server
disaptchers will handle the call if they can resolve a Request otherwise
they will forward. For client dispatchers they will handle the call and
always forward. The choice needs to be made for each dispatcher method
and may have implications on correct renderer import order. For now we
just live with the restriction that if you want to use server and client
together (such as renderToString in the browser) you need to import the
server renderer after the client renderer.

DiffTrain build for commit https://github.com/facebook/react/commit/113ab9af08c46e8a548a397154f5c9dfeb96ab6a.
2024-03-04 20:30:53 +00:00
gnoff 7a7b277b12 [DOM] disable legacy mode behind flag (#28468)
Adds a flag to disable legacy mode. Currently this flag is used to cause
legacy mode apis like render and hydrate to throw. This change also
removes render, hydrate, unmountComponentAtNode, and
unstable_renderSubtreeIntoContainer from the experiemntal entrypoint.
Right now for Meta builds this flag is off (legacy mode is still
supported). In OSS builds this flag matches __NEXT_MAJOR__ which means
it currently is on in experiemental. This means that after merging
legacy mode is effectively removed from experimental builds. While this
is a breaking change, experimental builds are not stable and users can
pin to older versions or update their use of react-dom to no longer use
legacy mode APIs.

DiffTrain build for commit https://github.com/facebook/react/commit/1c02b9d2bdc18091cc6afec810fc1b361f00abdd.
2024-03-04 16:22:54 +00:00
rickhanlonii a3ac61c6cb Fix Broken Links In Documentation (#28321)
## Summary

I used [link-inspector](https://github.com/justindhillon/link-inspector)
to find a bunch of broken links in this projects documentation. Here is
what I fixed:

https://www.html5rocks.com/en/tutorials/canvas/hidpi/ -->
https://web.dev/articles/canvas-hidipi

https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
--> https://www.w3.org/TR/custom-elements/

https://github.com/facebookarchive/fixed-data-table/blob/main/src/vendor_upstream/dom/normalizeWheel.js
-->
https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js

https://upload.wikimedia.org/wikipedia/commons/e/ee/Atom_%282%29.png -->
https://upload.wikimedia.org/wikipedia/commons/1/1b/Atom.png

## Support my work

I used [link-inspector](https://github.com/justindhillon/link-inspector)
to find and fix this issue. If you find this PR useful, give the repo a


DiffTrain build for commit https://github.com/facebook/react/commit/034130c02ffb47b0026059b57d17e9b080976ff3.
2024-03-03 22:47:58 +00:00
rickhanlonii d27934ba7c Update /link URLs to react.dev (#28477)
Depends on https://github.com/reactjs/react.dev/pull/6670 [merged]

DiffTrain build for commit https://github.com/facebook/react/commit/1940cb27b260c2eab79c76763d1151ba18353ff8.
2024-03-03 22:39:24 +00:00
gnoff c6a82952c8 [devtools][tests] add support for @gate pragma (#28479)
Adds support for `// @gate` pragma in devtools tests
Adds a couple gate test assertions to ensure they continue to work

DiffTrain build for commit https://github.com/facebook/react/commit/30ae0baed1cfe670dea41d7c7abdc375c9a4859a.
2024-03-01 21:31:08 +00:00
gaearon 4d4f3a8fc5 Remove loose-envify dep and browserify configs (#28480)
Browserify isn't widely used, and at this point I don't think it makes
sense to have a special config just for the sake of it. Let's remove it?

DiffTrain build for commit https://github.com/facebook/react/commit/11828bf529ed1b1c1b94e7afe9da2ea072316d8e.
2024-03-01 20:54:23 +00:00
rickhanlonii bb5380b044 Update homepage URLs to react.dev (#28478)
Updates the package.json "homepage" entry to react.dev

DiffTrain build for commit https://github.com/facebook/react/commit/5f2c6b74db031991ff2cdee2767c4d006ddc83d7.
2024-03-01 19:39:10 +00:00
acdlite fc46af013a Move ref type check to receiver (#28464)
The runtime contains a type check to determine if a user-provided ref is
a valid type — a function or object (or a string, when
`disableStringRefs` is off). This currently happens during child
reconciliation. This changes it to happen only when the ref is passed to
the component that the ref is being attached to.

This is a continuation of the "ref as prop" change — until you actually
pass a ref to a HostComponent, class, etc, ref is a normal prop that has
no special behavior.

DiffTrain build for commit https://github.com/facebook/react/commit/2f8f7760223241665f472a2a9be16650473bce39.
2024-03-01 02:30:16 +00:00
rickhanlonii dbab28df46 Clean up empty string special cases (#28475)
This was fixed in https://github.com/facebook/react/pull/22807 so we
don't need these special cases anymore.

DiffTrain build for commit https://github.com/facebook/react/commit/bb4b147da9a892529995f55f15f19f46a00cf4f6.
2024-03-01 01:31:16 +00:00
kassens 02ba30aa4f Add dynamic flag for infinite loop detection on React Native FB (#28456)
Add dynamic flag for infinite loop detection on React Native FB

DiffTrain build for commit https://github.com/facebook/react/commit/b8da12e8f8e6a6b087f6531c1c791ab41e5273d4.
2024-02-29 21:24:50 +00:00
eps1lon 4942d003d6 Devtools: Unwrap Promise in useFormState (#28319)
DiffTrain build for commit https://github.com/facebook/react/commit/fb10a2c66a923d218471b535fdaf0dbc530417ee.
2024-02-28 22:57:59 +00:00
eps1lon 2c5bcad441 Run yarn flags in CI (#28345)
DiffTrain build for commit https://github.com/facebook/react/commit/01ab35a9a731dec69995fbd28f3ac7eaad11e183.
2024-02-27 23:16:33 +00:00
rickhanlonii a969bc1ff5 Move enableRenderableContext back to dynamic (#28466)
DiffTrain build for commit https://github.com/facebook/react/commit/d88fb321a3c5ccadb9d617364b6f50cb943765eb.
2024-02-27 23:16:21 +00:00
eps1lon 369b2714ee Remove ReactTestUtils from ReactJSXRuntime (#28337)
DiffTrain build for commit https://github.com/facebook/react/commit/c6bb12edd081423f3640285a08a04c2b41518a56.
2024-02-27 23:15:55 +00:00
eps1lon 62767e474f Remove ReactTestUtils from ReactJSXElementValidator (#28335)
DiffTrain build for commit https://github.com/facebook/react/commit/e7849b50bcefc0742ca342d70284d82cfcf990e5.
2024-02-27 23:15:44 +00:00
rickhanlonii efee0c2be4 Turn on disableJavaScriptURLs for experimental (#28462)
This is on everywhere, ready to turn on in the next major.

DiffTrain build for commit https://github.com/facebook/react/commit/dee1aac77f71e887c44bb79ecfe9c7a34ab3e74c.
2024-02-27 21:37:19 +00:00
acdlite 161ee2460d Remove string refs (behind flag) (#28322)
Depends on:

- https://github.com/facebook/react/pull/28398

---

This removes string refs, which has been deprecated in Strict Mode for
seven years.

I've left them behind a flag for Meta, but in open source this fully
removes the feature.

DiffTrain build for commit https://github.com/facebook/react/commit/c9798954e26a2354a951cc65607f2901a45bf035.
2024-02-27 16:46:50 +00:00
noahlemen ae4690b594 clean up isInputPending in Scheduler (#28444)
## Summary

`isInputPending` is not in use. This PR cleans up the flags controlling
its gating and parameters to simplify Scheduler.

Makes `frameYieldMs` feature flag static, set to 10ms in www, which we
found built on the wins provided by a broader yield interval via
`isInputPending`. Flag remains set to 5ms in OSS builds.

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

DiffTrain build for commit https://github.com/facebook/react/commit/3bcd2de01b5716202eabe8faa338f51bdc59ce26.
2024-02-27 15:43:16 +00:00
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