Commit Graph

14441 Commits

Author SHA1 Message Date
salazarm 031abd24b6 Add warning and test for useSyncExternalStore when getSnapshot isn't cached (#22262)
* add warning and test

* Wrap console error in __DEV__ flag

* prettier
2021-09-07 09:08:33 -07:00
Brian Vaughn e07039bb61 Moved named hooks code (and tests) from react-devtools-extensions to react-devtools-shared (#22260) 2021-09-07 11:44:49 -04:00
Juan abbc79d6fd [DevTools] Only call originalPositionFor once (#22181) 2021-09-07 10:39:55 -04:00
Dan Abramov 771da6e27b Update PULL_REQUEST_TEMPLATE.md 2021-09-07 07:54:34 +01:00
Ryota Murakami d1f51f3453 [package:react-dom] updateREADME's Class Component to Function Component (#21829)
* [package:react-dom] updateREADME's Class Component to Function Component

* Update README.md

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2021-09-06 21:23:13 +01:00
Jianhua Zheng b8884de24e break up import keyword to avoid being accidentally parsed as dynamic import statement in external code (#21918)
Co-authored-by: zhengjianhua <zhengjianhua.michael@bytedance.com>
2021-09-06 21:20:33 +01:00
Ikko Ashimine 6d6bba5bfc Fix typo in ReactUpdatePriority-test.js (#21958)
continous -> continuous
2021-09-06 21:16:05 +01:00
Dan Abramov 37abc99418 Build ReactDOMServer on CodeSandbox CI (#22255) 2021-09-06 21:00:36 +01:00
Michaël De Boey b394c38e88 feat(eslint-plugin-react-internal): support ESLint 8.x (#22249)
Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2021-09-06 20:42:40 +01:00
Dan Abramov 6f64eb5aa0 Update PULL_REQUEST_TEMPLATE.md 2021-09-06 20:36:46 +01:00
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