Commit Graph

13306 Commits

Author SHA1 Message Date
Sebastian Markbåge a30a1c6ef3
Transfer actualDuration only once for SuspenseList (#18959) 2020-05-20 15:12:38 -07:00
Andrew Clark 8b3b5c3524
Bugfix: Missing mode check in resetChildLanes (#18961)
Deferring a hidden tree is only supported in Concurrent Mode.

The missing check leads to an infinite loop when an update is scheduled
inside a hidden tree, because the pending work never gets reset.

This "accidentally" worked in the old reconciler because the heurstic
we used to detect offscreen trees was if `childExpirationTime`
was `Never`.

In the new reconciler, we check the tag instead. Which means we also
need to check the mode, like we do in the begin phase.

We should move this check out of the hot path. It shouldn't have been
in the hot path of the old reconciler, either.

Probably by moving `resetChildLanes` into the switch statement
in ReactFiberCompleteWork.
2020-05-19 23:10:49 -07:00
Andrew Clark 95ea8ed47c
LegacyHidden: mode that defers without hiding (#18958)
Need this to unblock www. Not sure yet how we'll support this properly
long term.

While adding this, I noticed that the normal "hidden" mode of
LegacyHidden doesn't work properly because it doesn't toggle the
visibility of newly inserted nodes. This is fine for now since we only
use it via a userspace abstraction that wraps the children in an
additional node. But implementing this correctly is required for us
to start using it like a fragment, without the wrapper node.
2020-05-19 15:58:02 -07:00
Brian Vaughn 5aa967b69b
DevTools editable props tweaks (#18954)
1. Made non-editable prop text higher contrast (easier to read)
2. Also makes it stand out as different from dimmer placeholder text for "new prop"
2020-05-19 09:42:00 -07:00
Toru Kobayashi dbf2bba632
remove an unused ISSUE_TEMPLATE.md (#18953) 2020-05-19 08:44:01 -07:00
Brian Vaughn 23309eb386 DevTools 4.6.0 -> 4.7.0 2020-05-18 14:16:04 -07:00
Nick Reiley d897c35ecf
[DevTools] Add Component Highlighting to Profiler (#18745)
Co-authored-by: Moji Izadmehr <m.eezadmehr@gmail.com>
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-05-18 11:13:16 -07:00
Nick Reiley 081b565cd7
[DevTools] enable Electron interactions on Linux & auto copy script tags (#18772)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-18 10:27:40 -07:00
Sebastian Silbermann c390ab3643
Add test for displayName on React.memo components (#18925)
* Add test for displayName on React.memo components

* Added extra memo displayName test

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-15 15:56:50 -07:00
Gabriele Prestifilippo 6ed5c2243f
Add MIT license to use-subscription package (#18927)
This package is missing the license attribute (or a license file).

Being a sub-package of React, it should get the same license, however, none was specified.
A scan with `license_checker` would recognize this as `UNKNOWN`.
2020-05-15 15:36:48 -07:00
Brian Vaughn 8dba6691d0 Updated DevTools CHANGELOG for upcoming changes 2020-05-15 10:50:39 -07:00
Nick Reiley dd2e36df33
Profiler: Skip reading element for imported data (#18913)
* skip reading element for imported data

* rename nodes & enable store lookup for components tab

* replace names

* Added some more test coverage; reverted rename

Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-05-15 10:38:01 -07:00
Nick Reiley 7c080902ef
[DevTools] Improve HOC search UX (#18802)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-15 10:37:34 -07:00
Ricky Vetter 121af3143c
Update inaccurate mapChildren comment (#18931)
The function you provide will only be passed a child and an index. It will not be passed a key. This is confirmed in the source, the Flow types, and the jsdoc comments.
2020-05-15 18:05:08 +01:00
Sophie Alpert 21dc41c320
Simplify logic for mutable workInProgressSources (#18920)
isPrimaryRenderer is always constant for a given React build, so these two arrays do nothing.
2020-05-14 14:30:44 -07:00
Andrew Clark 0fb747f368
Add LegacyHidden to server renderer (#18919)
* Add LegacyHidden to server renderer

When the tree is hidden, the server renderer renders nothing. The
contents will be completely client rendered.

When the tree is visible it acts like a fragment.

The future streaming server renderer may want to pre-render these trees
and send them down in chunks, as with Suspense boundaries.

* Force client render, even at Offscreen pri
2020-05-14 11:28:11 -07:00
Andrew Clark b4a1a4980c
Disable <div hidden /> API in old fork, too (#18917)
The motivation for doing this is to make it impossible for additional
uses of pre-rendering to sneak into www without going through the
LegacyHidden abstraction. Since this feature was already disabled in
the new fork, this brings the two closer to parity.

The LegacyHidden abstraction itself still needs to opt into
pre-rendering somehow, so rather than totally disabling the feature, I
updated the `hidden` prop check to be obnoxiously specific. Before, you
could set it to any truthy value; now, you must set it to the string
"unstable-do-not-use-legacy-hidden".

The node will still be hidden in the DOM, since any truthy value will
cause the browser to apply a style of `display: none`.

I will have to update the LegacyHidden component in www to use the
obnoxious string prop. This doesn't block merge, though, since the
behavior is gated by a dynamic flag. I will update the component before
I enable the flag.
2020-05-13 20:01:10 -07:00
Brian Vaughn 9e5b2c94e6
Add expando prop to disabledLog function (#18914)
This will enable it to be identified by Facebook infra even if the function name is mangled during DevTools build process.
2020-05-13 17:03:50 -07:00
Andrew Clark fdb641629e
Fix useMutableSource tearing bug (#18912)
* Failing useMutableSource test

If a source is mutated after initial read but before subscription is set
up, it should still entangle all pending mutations even if snapshot of
new subscription happens to match.

Test case illustrates how not doing this can lead to tearing.

* Fix useMutableSource tearing bug

Fix is to move the entanglement call outside of the block that checks
if the snapshot has changed.
2020-05-13 14:28:17 -07:00
Andrew Clark 33589f7423
useMutableSource: "Entangle" instead of expiring (#18889)
* useMutableSource: "Entangle" instead of expiring

A lane is said to be entangled with another when it's not allowed to
render in a batch that does not also include the other lane.

This commit implements entanglement for `useMutableSource`. If a source
is mutated in between when it's read in the render phase, but before
it's subscribed to in the commit phase, we must account for whether the
same source has pending mutations elsewhere. The old subscriptions must
not be allowed to re-render without also including the new subscription
(and vice versa), to prevent tearing.

In the old reconciler, we did this by synchronously flushing all the
pending subscription updates. This works, but isn't ideal. The new
reconciler can entangle the updates without de-opting to sync.

In the future, we plan to use this same mechanism for other features,
like skipping over intermediate useTransition states.

* Use clz instead of ctrz to pick an arbitrary lane

Should be slightly faster since most engines have built-in support.
2020-05-13 11:33:32 -07:00
Dan Abramov 43063fd844 eslint-plugin-react-hooks@4.0.2 2020-05-13 16:46:26 +01:00
Dan Abramov f6ff4c43dd
Update changelog 2020-05-13 16:45:50 +01:00
Boris Sergeev 487c693846
[eslint-plugin-react-hooks] useWithoutEffectSuffix fix (#18902) (#18907)
* [eslint-plugin-react-hooks] reproduce bug with a test and fix it (#18902)

Since we only reserve `-Effect` suffix, react-hooks/exhaustive-deps is
expected to succeed without warning on a custom hook which contains -Effect- in
the middle of it's name (but does NOT contain it as a suffix).

* [eslint-plugin-react-hooks] reproduced bug with a test and fix it

Since we only reserve `-Effect` suffix, react-hooks/exhaustive-deps is expected
to succeed without warning on a render helper which contains -use- in the middle
of it's name (but does NOT contain it as a prefix, since that would violate hook
naming convetion).

Co-authored-by: Boris Sergeyev <boris.sergeyev@quolab.com>
2020-05-13 16:44:05 +01:00
Dominic Gannaway 6514e4a179
React Flare: fix PressLegacy preventDefault issue (#18904) 2020-05-13 13:59:32 +01:00
Nick Reiley a3fccd2567
Fix Profiler root change error (#18880) 2020-05-12 15:47:23 -07:00
Dominic Gannaway 61f2a560e0
Add experimental ReactDOM.createEventHandle (#18756) 2020-05-12 20:24:25 +01:00
Dan Abramov 84fd4b853f
Revert "deps: update ESLint version to v7 (#18897)" (#18899)
This reverts commit 039ad34a05.
2020-05-12 20:06:14 +01:00
Dan Abramov 14e554b310
Add missing changelog item 2020-05-12 19:18:26 +01:00
Dominic Gannaway 80c4dea0d1
Modern Event System: Add scaffolding for createEventHandle (#18898) 2020-05-12 19:01:12 +01:00
Toru Kobayashi 039ad34a05
deps: update ESLint version to v7 (#18897) 2020-05-12 18:41:37 +01:00
Dan Abramov 9f396bdd5d eslint-plugin-react-hooks@4.0.1 2020-05-12 17:22:00 +01:00
Richard Maisano c512aa0081
[Blocks] Scaffolding react-fetch + first pass at node implementation (#18863)
* First pass at scaffolding out the Node implementation of react-data.

While incomplete, this patch contains some changes to the react-data
package in order to start adding support for Node.

The first part of this change accounts for splitting react-data/fetch
into two discrete entries, adding (and defaulting to) the Node
implementation.

The second part is sketching out a rough approximation of `fetch` for
Node. This implementation is not complete by any means, but provides a
starting point.

* Remove NodeFetch module and put it directly into ReactDataFetchNode.

* Replaced react-data with react-fetch.

This patch shuffles around some of the scaffolding that was in
react-data in favor of react-fetch. It also removes the additional
"fetch" package in favor of something flatter.

* Tweak package organization

* Simplify and add a test

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2020-05-12 17:21:45 +01:00
Dan Abramov e936034eec
Add item to ESLint Hooks plugin changelog 2020-05-12 17:02:37 +01:00
Michaël De Boey c3ff21e01b
feat(eslint-plugin-react-hooks): Support ESLint 7.x (#18878) 2020-05-12 17:01:28 +01:00
Andrew Clark 8b9c4d1688
Expose LegacyHidden type and disable <div hidden /> API in new fork (#18891)
* Expose LegacyHidden type

I will use this internally at Facebook to migrate away from
<div hidden />. The end goal is to migrate to the Offscreen type, but
that has different semantics. This is an incremental step.

* Disable <div hidden /> API in new fork

Migrates to the unstable_LegacyHidden type instead. The old fork does
not support the new component type, so I updated the tests to use an
indirection that picks the correct API. I will remove this once the
LegacyHidden (and/or Offscreen) type has landed in both implementations.

* Add gated warning for `<div hidden />` API

Only exists so we can detect callers in www and migrate them to the new
API. Should not visible to anyone outside React Core team.
2020-05-11 20:02:08 -07:00
Dominic Gannaway ef0bf8e31c
Revert "Hard code enableComponentStacks in www (#18869)" (#18890)
This reverts commit fd696df472.
2020-05-11 23:29:24 +01:00
Dominic Gannaway e16703e6c7
Modern Event System: revise ancestor logic (#18886) 2020-05-11 22:09:52 +01:00
Karl Horky 2b9d7cf65f
Devtools: Show inspectedElement `key` in right pane (#18737)
* Start MVP for showing inspected element key

* Add key in other places

* Add key from backend

* Remove unnecessary hydrateHelper call

* Hide copy button when no label

* Move above props

* Revert changes to InspectedElementTree.js

* Move key to left of component name

* Updated CSS

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-11 13:17:13 -07:00
Rohith Srivathsav ddcc69c83b
Added clear message for functional component starting with lowercase (#18881) 2020-05-10 01:52:11 +01:00
Sebastian Markbåge 539527b642
Don't cut off effects at end of list if hydrating (#18872) 2020-05-08 21:26:51 -07:00
Sebastian Markbåge fd696df472
Hard code enableComponentStacks in www (#18869)
This is now fully rolled out.
2020-05-08 18:14:54 -07:00
Andrew Clark 6edaf6f764
Detect and prevent render starvation, per lane (#18864)
* Detect and prevent render starvation, per lane

If an update is CPU-bound for longer than expected according to its
priority, we assume it's being starved by other work on the main thread.

To detect this, we keep track of the elapsed time using a fixed-size
array where each slot corresponds to a lane. What we actually store is
the event time when the lane first became CPU-bound.

Then, when receiving a new update or yielding to the main thread, we
check how long each lane has been pending. If the time exceeds a
threshold constant corresponding to its priority, we mark it as expired
to force it to synchronously finish.

We don't want to mistake time elapsed while an update is IO-bound
(waiting for data to resolve) for time when it is CPU-bound. So when a
lane suspends, we clear its associated event time from the array. When
it receives a signal to try again, either a ping or an update, we assign
a new event time to restart the clock.

* Store as expiration time, not start time

I originally stored the start time because I thought I could use this
in the future to also measure Suspense timeouts. (Event times are
currently stored on each update object for this purpose.) But that
won't work because in the case of expiration times, we reset the clock
whenever the update becomes IO-bound. So to replace the per-update
field, I'm going to have to track those on the room separately from
expiration times.
2020-05-08 12:47:51 -07:00
Nick Reiley 6207743168
[DevTools] Allow to continue dragging when leaving profiler picker (#18852)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-08 11:19:57 -07:00
Luna Ruan df14b5bcc1
add new IDs for each each server renderer instance and prefixes to distinguish between each server render (#18576)
There is a worry that `useOpaqueIdentifier` might run out of unique IDs if running for long enough. This PR moves the unique ID counter so it's generated per server renderer object instead. For people who render different subtrees, this PR adds a prefix option to `renderToString`, `renderToStaticMarkup`, `renderToNodeStream`, and `renderToStaticNodeStream` so identifiers can be differentiated for each individual subtree.
2020-05-07 20:46:27 -07:00
Brian Vaughn 69e732ac9d
Disable Profiler commit filtering (#18862)
* Disable Profiler commit filtering

We used to filter "empty" DevTools commits, but it was error prone (see #18798). A commit may appear to be empty (no actual durations) because of component filters, but filtering these empty commits causes interaction commit indices to be off by N. This not only corrupts the resulting data, but also potentially causes runtime errors.

For that matter, hiding "empty" commits might cause confusion too. A commit *did happen* even if none of the components the Profiler is showing were involved.

* Restart flaky CI
2020-05-07 17:07:20 -07:00
Brian Vaughn fb3f0acad9
Disable Webpack setImmediate polyfill for DevTools (#18860)
* Upgrade Webpack deps to latet

* Disable Webpack setImmediate polyfill
2020-05-07 13:13:47 -07:00
Sebastian Markbåge edf6eac8a1
Don't cut off the tail of a SuspenseList if hydrating (#18854) 2020-05-06 23:51:46 -07:00
Sebastian Markbåge 55f5cdee01
Disable setState before mount in legacy mode (#18851)
We kind of "support" this pattern in legacy mode. It's only deprecated in
Concurrent Mode.
2020-05-06 20:30:59 -07:00
Andrew Clark 47ebc90b08
Put render phase update change behind a flag (#18850)
In the new reconciler, I made a change to how render phase updates
work. (By render phase updates, I mean when a component updates
another component during its render phase. Or when a class component
updates itself during the render phase. It does not include when
a hook updates its own component during the render phase. Those have
their own semantics. So really I mean anything triggers the "`setState`
in render" warning.)

The old behavior is to give the update the same "thread" (expiration
time) as whatever is currently rendering. So if you call `setState` on a
component that happens later in the same render, it will flush during
that render. Ideally, we want to remove the special case and treat them
as if they came from an interleaved event.

Regardless, this pattern is not officially supported. This behavior is
only a fallback. The flag only exists until we can roll out the
`setState` warnning, since existing code might accidentally rely on the
current behavior.
2020-05-06 19:19:14 -07:00
Dominic Gannaway 6778c53c16
Modern Event System: fix bug in EnterLeave (#18849) 2020-05-07 00:13:13 +01:00