Commit Graph

14431 Commits

Author SHA1 Message Date
Dan Abramov cdb08ebe0a
Update PULL_REQUEST_TEMPLATE.md 2021-09-06 20:36:24 +01:00
Michaël De Boey 0c0d1ddae4
feat(eslint-plugin-react-hooks): support ESLint 8.x (#22248) 2021-09-06 20:17:51 +01:00
Mahyar Ebadi 380284a2b4
Add aria-description to the list of known ARIA attributes (#22142)
* Update validAriaProperties.js

https://w3c.github.io/aria/#aria-description is a valid aria property.

* Sort alphabetically

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2021-09-06 20:12:51 +01:00
Kausik S S c46c0733e2
Typo fixed (#22171) 2021-09-06 20:05:15 +01:00
dependabot[bot] 6a56ea89bc
Bump tar from 5.0.5 to 5.0.11 (#22223)
Bumps [tar](https://github.com/npm/node-tar) from 5.0.5 to 5.0.11.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v5.0.5...v5.0.11)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-06 20:03:12 +01:00
Konstantin Popov 99f9de9a6a
Fix typo in ReactDOMServerFormatConfig.js (#22203)
Fix typo:

TOOD -> TODO
2021-09-06 19:58:46 +01:00
Andrew Clark 1314299c7f
Initial shim of useSyncExternalStore (#22211)
This sets up an initial shim implementation of useSyncExternalStore,
via the use-sync-external-store package. It's designed to mimic the
behavior of the built-in API, but is backwards compatible to any version
of React that supports hooks.

I have not yet implemented the built-in API, but once it exists, the
use-sync-external-store package will always prefer that one. Library
authors can depend on the shim and trust that their users get the
correct implementation.

See https://github.com/reactwg/react-18/discussions/86 for background
on the API.

The tests I've added here are designed to run against both the shim and
built-in implementation, using our variant test flag feature. Tests that
only apply to concurrent roots will live in a separate suite.
2021-09-01 17:52:38 -07:00
Luna Ruan 3385b377f7
React DevTools 4.17.0 -> 4.18.0 (#22234) 2021-09-01 13:39:36 -07:00
Luna Ruan 2b7214033e
[DevTools] Fix Issue in release script where commits for the last DevTools release are undefined #22233 2021-09-01 12:56:39 -07:00
Luna Ruan ac8fc34e61
remove dist folder in release script for standalone and inline before building (#22232) 2021-09-01 12:16:00 -07:00
Luna Ruan fc40f02adb
Add consoleManagedByDevToolsDuringStrictMode feature flag in React Reconciler (#22196) 2021-09-01 11:56:52 -07:00
Brian Vaughn 9fc04eaf3f
DevTools: Improve named hooks network caching (#22198)
While testing the recently-launched named hooks feature, I noticed that one of the two big performance bottlenecks is fetching the source file. This was unexpected since the source file has already been loaded by the page. (After all, DevTools is inspecting a component defined in that same file.)

To address this, I made the following changes:
- [x] Keep CPU bound work (parsing source map and AST) in a worker so it doesn't block the main thread but move I/O bound code (fetching files) to the main thread.
- [x] Inject a function into the page (as part of the content script) to fetch cached files for the extension. Communicate with this function using `eval()` (to send it messages) and `chrome.runtime.sendMessage()` to return its responses to the extension).

With the above changes in place, the extension gets cached responses from a lot of sites- but not Facebook. This seems to be due to the following:
* Facebook's response headers include [`vary: 'Origin'`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary).
* The `fetch` made from the content script does not include an `Origin` request header.

To reduce the impact of cases where we can't re-use the Network cache, this PR also makes additional changes:
- [x] Use `devtools.network.onRequestFinished` to (pre)cache resources as the page loads them. This allows us to avoid requesting a resource that's already been loaded in most cases.
- [x] In case DevTools was opened _after_ some requests were made, we also now pre-fetch (and cache in memory) source files when a component is selected (if it has hooks). If the component's hooks are later evaluated, the source map will be faster to access. (Note that in many cases, this prefetch is very fast since it is returned from the disk cache.)

With the above changes, we've reduced the time spent in `loadSourceFiles` to nearly nothing.
2021-09-01 14:10:07 -04:00
Luna Ruan 67f38366a5
Add consoleManagedByDevToolsDuringStrictMode feature flag in DevTools #22215 2021-08-30 15:16:53 -07:00
Luna Ruan 597ecd6a0c
[DevTools] Throw error in console without interfering with logs (#22175) 2021-08-30 14:37:49 -07:00
Luna Ruan 36f0005b99
added react native feature flags (#22199)
lunaruan commented 3 days ago • 
This PR adds separate DevTools feature flag configurations for react-devtools-core. It also breaks the builds down into facebook specific and open source flags so we can experiment in React Native.

Tested yarn build:standalone, yarn build:backend, yarn build:standalone:fb, and yarn build:backend:fb and inspected the output to make sure each package used the correct feature flags (the first two use core-oss and the latter two use fb-oss.
2021-08-30 14:12:52 -07:00
Sebastian Silbermann 5037b4e2e6
devtools: Don't display hook index of useContext (#22200) 2021-08-30 15:44:12 -04:00
Andrew Clark 46a0f050aa
Set up use-sync-external-store package (#22202)
This package will be a shim for the built-in useSyncExternalStore API
(not yet implemented).
2021-08-28 13:57:47 -07:00
Matt Hargett 8723e772b9
Fix a string interpolation typo in ReactHooks test (#22174) 2021-08-26 15:35:06 -04:00
Juan 0ba0564aee
[DevTools] Add utils for perfomance marks (#22180) 2021-08-26 13:05:15 -04:00
Brian Vaughn 2bf2e76d36
Add performance marksf or individual fetch() requests (#22176) 2021-08-26 09:19:00 -04:00
Luna Ruan 60a30cf32e
Console Logging for StrictMode Double Rendering (#22030)
React currently suppress console logs in StrictMode during double rendering. However, this causes a lot of confusion. This PR moves the console suppression logic from React into React Devtools. Now by default, we no longer suppress console logs. Instead, we gray out the logs in console during double render. We also add a setting in React Devtools to allow developers to hide console logs during double render if they choose.
2021-08-25 15:35:38 -07:00
Brian Vaughn 8456457c8d
Added performance timings to DevTools named hooks parsing (#22173) 2021-08-25 15:39:15 -04:00
Brian Vaughn b9964684bd
DevTools release script updates: (#22170) 2021-08-24 18:59:34 -04:00
Brian Vaughn 582858083e React DevTools 4.16.0 -> 4.17.0 2021-08-24 11:12:42 -07:00
Brian Vaughn b5fbf5464b
Automated DevTools release process (#22161) 2021-08-24 14:05:50 -04:00
Ricky 76bbad3e34
Add maxYieldMs feature flag in Scheduler (#22165) 2021-08-24 13:03:07 -04:00
Ricky b0b53ae2c1
Add feature flags for scheduler experiments (#22105) 2021-08-24 12:47:51 -04:00
Brian Vaughn edfe50510b
DevTools: Replaced WeakMap with LRU for inspected element cache (#22160)
We use an LRU for this rather than a WeakMap because of how the "no-change" optimization works.

When the frontend polls the backend for an update on the element that's currently inspected, the backend will send a "no-change" message if the element hasn't updated (rendered) since the last time it was asked. In thid case, the frontend cache should reuse the previous (cached) value. Using a WeakMap keyed on Element generally works well for this, since Elements are mutable and stable in the Store. This doens't work properly though when component filters are changed, because this will cause the Store to dump all roots and re-initialize the tree (recreating the Element objects).

So instead we key on Element ID (which is stable in this case) and use an LRU for eviction.
2021-08-23 19:22:31 -04:00
Byron Luk bd5bf555e1
add more detailed error handling if profiling data does not have any React marks (#22157)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2021-08-23 11:01:00 -04:00
Junaid Farooq 0da5ad09db
Renames master to main in fixtures/flight webpack config file (#21998) 2021-08-23 10:55:37 -04:00
Brian Vaughn 4df10c5871
Yarn replace-fork should not silently error (#22156) 2021-08-22 16:53:07 -04:00
Bowen fc3b6a4118
Fix a few typos (#22154)
Co-authored-by: Bowen Li <bowen31337@gmail.com>
2021-08-22 14:11:35 -04:00
Konstantin Popov f5e529176e
Fix typo in preprocessData.js (#22150)
Fix typo:

SUSPEND_DURING_UPATE  ->  SUSPEND_DURING_UPDATE
2021-08-22 13:37:36 -04:00
Juan 9e8fe11e11
[DevTools] Keep query params in extracted source map urls (#22148)
## Summary

Our current logic for extracting source map urls assumed that the url contained no query params (e.g. `?foo=bar`), and when extracting the url we would cut off the query params. I noticed this during internal testing, since removing the query params would cause loading source maps to fail.

This commit fixes that behavior by ensuring that our regex captures the full url, including query params.

## Test Plan

- yarn flow
- yarn test
- yarn test-build-devtools
- added new regression tests 
- named hooks still work on manual test of browser extension on a few different apps (code sandbox, create-react-app, internally).
2021-08-20 18:04:30 -04:00
Holger Benl 83205c0aea
[DevTools] Add options for disabling some features (#22136) 2021-08-20 12:55:50 -04:00
Brian Vaughn 75a3e9fa40
DevTools: Reset cached indices in Store after elements reordered (#22147) 2021-08-20 12:53:28 -04:00
Sebastian Silbermann b6ff9ad163
DevTools: update error indices when elements are added/removed (#22144) 2021-08-20 11:55:42 -04:00
Andrew Clark 986d0e61d7
[Scheduler] Add tests for isInputPending (#22140)
This feature was already implemented but we didn't have any tests. So
I wrote some.
2021-08-20 06:57:29 -07:00
Andrew Clark d54be90be6
Set up test infra for dynamic Scheduler flags (#22139)
I copied the set up we use for React.

In the www-variant test job, the Scheduler `__VARIANT__` flags will be
`true`. When writing a test, we can read the value of the flag with the
`gate` pragma and method.

Note: Since these packages are currently released in lockstep, maybe we
should remove SchedulerFeatureFlags and use ReactFeatureFlags for both.
2021-08-20 06:56:20 -07:00
Brian Vaughn 64f83a6fd2
Replace "source-map" library with "source-map-js" (#22126) 2021-08-19 11:25:38 -04:00
Brian Vaughn aa25824f3e
Scheduling profiler: Fix tooltip wheel event regression (#22130)
Panning horizontally via mouse wheel used to allow you to scrub over snapshot images. This was accidentally broken by a recent change. The core of the fix for this was to update `useSmartTooltip()` to remove the dependencies array so that a newly rendered tooltip is positioned even if the mouseX/mouseY coordinates don't change (as they don't when panning via wheel).

I also cleaned a couple of unrelated things up while doing this:
* Consolidated hover reset logic formerly split between `CanvasPage` and `Surface` into the `Surface` `handleInteraction()` function.
* Cleaned up redundant ref setting code in EventTooltip.
2021-08-18 19:51:34 -04:00
Juan 42ef45b129
[DevTools] Using array destructuring without assigning first variable does not error (#22129)
## Summary

Before this commit, if a hook returned an array the was destructured, but without assigning a variable to the first element in the array, this would produce an error. This was detected via internal testing.

This commit fixes that and adds regression tests.


## Test Plan

- yarn flow
- yarn test
- yarn test-build-devtools
- added new regression tests 
- named hooks still work on manual test of browser extension on a few different apps (code sandbox, create-react-app, internally).
2021-08-18 18:26:57 -04:00
Juan f1db9c30cc
[DevTools] Support object destructuring pattern without runtime errors (#22128)
## Summary

Before this commit, if a hook returned an object and we declared a variable using object destructuring on the returned value, we would produce a runtime error. This was detected via internal testing.

This commit fixes that and adds regression tests.


## Test Plan

- yarn flow
- yarn test
- yarn test-build-devtools
- added new regression tests 
- named hooks still work on manual test of browser extension on a few different apps (code sandbox, create-react-app, internally).
2021-08-18 18:17:29 -04:00
Dan Abramov 7ed0706d7e
Remove the warning for setState on unmounted components (#22114)
* Remove warning for setState on unmounted components

* Trigger CI
2021-08-18 21:50:02 +01:00
Juan 6abda7f4f2
[DevTools] Access metadata in source maps correctly accounting for different formats (#22096)
## Summary

Follow up from https://github.com/facebook/react/pull/22010.

The initial implementation of named hooks and for looking up hook name metadata in an extended source map both assumed that the source maps would always have a `sources` field available, and didn't account for the source maps in the [Index Map](https://sourcemaps.info/spec.html#h.535es3xeprgt) format, which contain a list of `sections` and don't have the `source` field available directly. 

In order to properly access metadata in extended source maps, this commit:

-  Adds a new `SourceMapMetadataConsumer` api, which is a fork / very similar in structure to the corresponding [consumer in Metro](2b44ec39b4/packages/metro-symbolicate/src/SourceMetadataMapConsumer.js (L56)) (as specified by @motiz88 in https://github.com/facebook/react/issues/21782.
- Updates `parseHookNames` to use this new api

## Test Plan

- yarn flow
- yarn test
- yarn test-build-devtools
- added new regression tests covering the index map format
- named hooks still work on manual test of browser extension on a few different apps (code sandbox, create-react-app, internally).
2021-08-18 14:30:31 -04:00
Brian Vaughn f51579fffe
Scheduling Profiler: Add network measures (#22112) 2021-08-18 12:17:59 -04:00
Brian Vaughn 9eb2aaaf81
Fixed ReactSharedInternals export in UMD bundle (#22117) 2021-08-18 01:40:55 -04:00
Sota bd255700d7
Show a soft error when a text string or number is supplied as a child to non text wrappers (#22109) 2021-08-16 21:43:24 -04:00
Sota 424fe58708
Revert "Show a soft error when a text string or number is supplied as a child to non text wrappers (#21953)" (#22108)
This reverts commit e9b2028b32.
2021-08-16 17:53:23 -07:00
Andrew Clark aebf3b456b
[Scheduler] Check for continuous input events (#22107)
* [Scheduler] Track start of current chunk

Currently in `shouldYield`, we compare the current time to a deadline
that is pre-computed at the beginning of the current chunk.

However, since we use different deadlines depending on whether an input
event is pending, it makes more sense to track the start of the current
chunk and check how much time has elapsed since then.

Doesn't change any behavior, just refactors the logic.

* [Scheduler] Check for continuous input events

`isInputPending` supports a `includeContinuous` option. When set to
`true`, the method will check for pending continuous inputs, like
`mousemove`, in addition to discrete ones, like `click`.

We will only check for pending continuous inputs if we've blocked the
main thread for a non-neglible amount of time. If we've only blocked
the main thread for, say, a few frames, then we'll only check for
discrete inputs.

I wrote a test for this but didn't include it because we haven't yet set
up the `gate` flag infra to work with Scheduler feature flags. For now,
I ran the test locally.

* Review nits
2021-08-16 15:48:50 -07:00