Commit Graph

22 Commits

Author SHA1 Message Date
Dan Abramov
e706721490
Update Flow to 0.84 (#17805)
* Update Flow to 0.84

* Fix violations

* Use inexact object syntax in files from fbsource

* Fix warning extraction to use a modern parser

* Codemod inexact objects to new syntax

* Tighten types that can be exact

* Revert unintentional formatting changes from codemod
2020-01-09 14:50:44 +00:00
Brian Vaughn
24f824250f
DevTools Profiler: Improve how empty commits are filtered (#17771)
Previously, DevTools filtered empty commits on the backend, while profiling, through the use of a bailout heuristic that React currently happens to use. This approach was brittle and may have exacerbated the long-standing Profiler bug #16446.

This PR removes that heuristic and adds as a post-processing filtering pass instead. This removes the coupling between DevTools and a React internal implementation detail that may change.

I believe DevTools has two choices of criteria for this filtering:
* Filter commits that have no actual duration metadata.
* Filter commits that have no recorded operations (no mutations to the tree, no changed tree base durations).

I chose the first option, filtering by commits that have no reported metadata. It will miss an edge case, e.g. , but we would have nothing meaningful to show in the Profiler for those cases anyway. (This particular edge case is why one of the snapshots changed with this commit.)

The second option, filtering by recorded operations, could potentially miss a more important edge case: where a component *did* render, but its  didn't change. (In that event, there would be no operations to send.)
2020-01-04 16:50:39 -08:00
Brian Vaughn
5d3d71b1dd
Partial fix DevTools Profiler ''Could not find node…'' error (#17759)
The Profiler stores:

1. A snapshot of the React tree when profiling started
2. The operations array for each commit
3. Profiling metadata (e.g. durations, what changed, etc) for each commit

It uses this information (snapshot + operations diff) to reconstruct the state of the application for a given commit as it's viewed in the Profiler UI. Because of this, it's very important that the operations and metadata arrays align. If they don't align, the profiler will be unable to correctly reconstruct the tree, and it will likely throw errors (like 'Could not find node…')

#16446 tracks a long-standing bug where these two arrays get misaligned. I am still not entirely sure what causes this bug, but with PR #17253, I exacerbated things by introducing another potential way for it to happen. This PR addresses the regression at least (and adds test coverage for it).

I will follow up this afternoon on the original #16446 issue. I think I may have a lead on what's happening at least, if not exactly an idea of how to reproduce it.
2020-01-03 09:28:31 -08:00
Brian Vaughn
933f6a07ca
DevTools context menu (#17608)
* Added rudimentary context menu hook and menu UI

* Added backend support for copying a value at a specific path for the inspected element

* Added backend support for storing a value (at a specified path) as a global variable

* Added special casing to enable copying undefined/unserializable values to the clipboard

* Added copy and store-as-global context menu options to selected element props panel

* Store global variables separately, with auto-incremented name (like browsers do)

* Added tests for new copy and store-as-global backend functions

* Fixed some ownerDocument/contentWindow edge cases

* Refactored context menu to support dynamic options

Used this mechanism to add a conditional menu option for inspecting the current value (if it's a function)

* Renamed "safeSerialize" to "serializeToString" and added inline comment
2019-12-18 12:12:34 -08:00
zthxxx
24dbe851e8 fix(dev-tools): fix show correct displayName with forwardRef in Dev Tools (#17613)
* fix(dev-tools): fix show correct displayName with forwardRef in Dev Tools

allow set `displayName` after `React.forwardRef()`,
makesure Dev Tools show displayName as same as `getWrappedName` in `shared/getComponentName.js`

* Removed a little unnecessary/redundant code.

* Fixed lint error (removed unused var)
2019-12-17 11:29:16 -08:00
Brian Vaughn
3452706308
DevTools cleanup (#17283)
1. Add a Store test for memo, lazy, and forwardRef components
2. Remove dead code for React.lazy
3. Update DT tests to include HOC badge names in the serialized store
2019-11-05 22:19:10 -08:00
Waseem Dahman
4f02c93c7c Fix devtools displaying Anonymous for memo of ref-forwarding components (#17274)
* [react-is] return correct typeOf value of forwardRef

* [react-devtools-shared] use correct displayName of memo(forwardRef(Component))

* [react-devtools-shared] add resolveFiberType and resolve fiber type of memo recursively

Resolving the fiber type of memo recursively before passing it to getDisplayName
will prevent it from displaying "Anonymous" as displayName for components
wrapped with both memo and forwardRef: memo(forwardRef(Component))

* rework resolveFiberType
2019-11-05 14:08:01 -08:00
Brian Vaughn
36fd29f09f
Don't show empty (no work) commits in Profiler (#17253) 2019-11-01 15:51:39 -07:00
Brian Vaughn
3497ccc149
Add guard to handle modified React elements with non-string keys (#17164) 2019-10-29 08:41:48 -07:00
Sebastian Markbåge
3cc564547c
SuspenseList support in DevTools (#17145)
* SuspenseList support in DevTools

This adds SuspenseList tags to DevTools so that the name properly shows
up.

It also switches to use the tag instead of Symbol type for Suspense
components. We shouldn't rely on the type for any built-ins since that
field will disappear from the fibers. How the Fibers get created is an
implementation detail that can change e.g. with a compiler or if we
use instanceof checks that are faster than symbol comparisons.

* Add SuspenseList test to shell app
2019-10-18 17:18:36 -07:00
Brian Vaughn
0545f366d4
Added trace updates feature (DOM only) (#16989)
* Added trace updates feature (DOM only)
* Updated DevTools CHANGELOG
2019-10-03 11:07:18 -07:00
Dominic Gannaway
57bf275fbd
[devtools] Add support for React Scope symbol/number (#16893) 2019-09-25 19:03:37 +02:00
Hristo Kanchev
4ef6387d6e [DevTools] [Context] Legacy Context (#16617)
* Added hasLegacyContext check.

* Passed hasLegacyContext as prop to SelectedElement

* Changing context labels based on hasLegacyContext

* Fixed flow types.

* Fixed typos.

* Added tests for hasLegacyContext.

* Renamed test.

* Removed test imports.
2019-09-10 13:30:20 -07:00
Brian Vaughn
8e1434e80e Added FB copyright header 2019-08-27 10:54:01 -07:00
Brian Vaughn
8c684bf7e1 Removed forked DevTools Flow types 2019-08-27 10:42:02 -07:00
Brian Vaughn
9d4fd7a249 Merged changes from 4.0.5 -> 4.0.6 from DevTools fork 2019-08-26 10:12:18 -07:00
Brian Vaughn
4da836af71 Merged changes from 4.0.0 -> 4.0.5 from DevTools fork 2019-08-20 11:34:51 -07:00
Brian Vaughn
ac2e861fbe Fixed a bunch of Lint issues 2019-08-13 21:59:07 -07:00
Brian Vaughn
183f96f2ac Prettier 2019-08-13 17:58:03 -07:00
Brian Vaughn
edc46d7be7 Misc Flow and import fixes
1. Fixed all reported Flow errors
2. Added a few missing package declarations
3. Deleted ReactDebugHooks fork in favor of react-debug-tools
2019-08-13 17:53:28 -07:00
Brian Vaughn
08743b1a8e Reorganized folders into packages/* 2019-08-13 15:59:43 -07:00
Brian Vaughn
ec7ef50e8b Reorganized things again into packages 2019-08-13 11:37:25 -07:00