Commit Graph

12944 Commits

Author SHA1 Message Date
dependabot[bot]
b78c419d7a
Bump minimist from 1.2.0 to 1.2.2 in /scripts/bench
Bumps [minimist](https://github.com/substack/minimist) from 1.2.0 to 1.2.2.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.0...1.2.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-03-16 19:52:56 +00:00
Brian Vaughn
297f7588c4
Moved passive effects flag to be beside execution context (#18322) 2020-03-16 10:27:42 -07:00
Jovi De Croock
95df39b6b1
improve error message for cross-functional component updates (#18316)
* improve error message for cross-functional component updates

* correctly use %s by quoting it

* use workInProgress and lint

* add test assertion

* fix test

* Improve the error message

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2020-03-16 17:05:30 +00:00
Brian Vaughn
c0ed0a2468
Replace passive effect context with boolean (#18309) 2020-03-16 09:56:43 -07:00
Brian Vaughn
730389b9d3
Warn against state updates from useEffect destroy functions (#18307)
Don't warn about unmounted state updates from within passive destroy function

* Fixed test conditional. (It broke after recent variant refactor.)
* Changed warning wording for setState from within useEffect destroy callback
2020-03-13 15:33:50 -07:00
Dominic Gannaway
0705b7282f
Refine event system types + pass through priority (#18305) 2020-03-13 17:57:17 +00:00
Dominic Gannaway
45d26f6edb
Remove un-used function arg (#18303) 2020-03-13 14:16:12 +00:00
Dan Abramov
73ff8b9094
Run ReactElementJSX-test against bundles (#18301)
* Run ReactElementJSX-test against bundles

* Try the new thing
2020-03-13 12:07:22 +00:00
Andrew Clark
8c015e0e14
Revert "Move MS Windows build to CircleCI (#17984)" (#18302)
This reverts commit 885ed46909.
2020-03-12 20:57:13 -07:00
wittgenst
885ed46909
Move MS Windows build to CircleCI (#17984)
* Move MS Windows build to CircleCI

* Update to latest NodeJS

Co-authored-by: Chris Lüer <lueer@fb.com>
2020-03-12 17:15:30 -07:00
Dominic Gannaway
2a7cd58956
ReactDOM.useEvent: Add DOM host event listener logic (#18292) 2020-03-12 22:41:33 +00:00
Dominic Gannaway
d3ec42020d
Address feedback for accumulateTwoPhaseListeners (#18289) 2020-03-12 21:48:29 +00:00
Andrew Clark
cd48a06547
Set up infra for react-reconciler fork (#18285)
* ReactFiberReconciler -> ReactFiberReconciler.old

* Set up infra for react-reconciler fork

We're planning to land some significant refactors of the reconciler.
We want to be able to gradually roll out the new implementation side-by-
side with the existing one. So we'll create a short lived fork of the
react-reconciler package. Once the new implementation has stabilized,
we'll delete the old implementation and promote the new one.

This means, for as long as the fork exists, we'll need to maintain two
separate implementations. This sounds painful, but since the forks will
still be largely the same, most changes will not require two separate
implementations. In practice, you'll implement the change in the old
fork and then copy paste it to the new one.

This commit only sets up the build and testing infrastructure. It does
not actually fork any modules. I'll do that in subsequent PRs.

The forked version of the reconciler will be used to build a special
version of React DOM. I've called this build ReactDOMForked. It's only
built for www; there's no open source version.

The new reconciler is disabled by default. It's enabled in the
`yarn test-www-variant` command. The reconciler fork isn't really
related to the "variant" feature of the www builds, but I'm piggy
backing on that concept to avoid having to add yet another
testing dimension.
2020-03-12 11:38:32 -07:00
Andrew Clark
615df434bb
Remove manual feature flag overrides (#18291)
Tests now run against both versions of these flags, using the
test-www-variant command. So we can remove the manual overrides.
2020-03-12 10:17:02 -07:00
Dominic Gannaway
99d271228d
ReactDOM.useEvent: more scaffolding changes (#18282) 2020-03-12 09:12:06 +00:00
Brian Vaughn
97a8c72bf8
Wrap Components and Profiler tabs with box-size style too (#18286)
For the browser extension, these views get rendered into portals and so they don't inherit the box-sizing style from the .DevTools wrapper element. This causes views like the Profiler commit selector to subtly break.
2020-03-11 19:12:57 -07:00
Andrew Clark
5374919033 Empty commit to fix CI on master
Weird GitHub bug caused CI jobs to run against master as if it was
a PR. Now it looks like master is failing, even though it isn't.

Bloop.
2020-03-11 18:29:46 -07:00
Dominic Gannaway
8b155d2613
Flow type ReactDOMComponentTree (#18280) 2020-03-11 19:38:23 +00:00
Brian Vaughn
322cdcd3ab
useMutableSource hook (#18000)
useMutableSource hook

useMutableSource() enables React components to safely and efficiently read from a mutable external source in Concurrent Mode. The API will detect mutations that occur during a render to avoid tearing and it will automatically schedule updates when the source is mutated.

RFC: reactjs/rfcs#147
2020-03-11 12:34:39 -07:00
Dominic Gannaway
30a998debf
ModernEventSystem: refactor accumulateTwoPhaseListeners (#18274) 2020-03-11 18:55:01 +00:00
Andrew Clark
8fe066fdac
Bugfix: "Captured" updates on legacy queue (#18265)
* Bugfix: "Captured" updates on legacy queue

This fixes a bug with error boundaries. Error boundaries have a notion
of "captured" updates that represent errors that are thrown in its
subtree during the render phase. These updates are meant to be dropped
if the render is aborted.

The bug happens when there's a concurrent update (an update from an
interleaved event) in between when the error is thrown and when the
error boundary does its second pass. The concurrent update is
transferred from the pending queue onto the base queue. Usually, at this
point the base queue is the same as the current queue. So when we
append the pending updates to the work-in-progress queue, it also
appends to the current queue.

However, in the case of an error boundary's second pass, the base queue
has already forked from the current queue; it includes both the
"captured" updates and any concurrent updates. In that case, what we
need to do is append separately to both queues. Which we weren't doing.

That isn't the full story, though. You would expect that this mistake
would manifest as dropping the interleaved updates. But instead what
was happening is that the "captured" updates, the ones that are meant
to be dropped if the render is aborted, were being added to the
current queue.

The reason is that the `baseQueue` structure is a circular linked list.
The motivation for this was to save memory; instead of separate `first`
and `last` pointers, you only need to point to `last`.

But this approach does not work with structural sharing. So what was
happening is that the captured updates were accidentally being added
to the current queue because of the circular link.

To fix this, I changed the `baseQueue` from a circular linked list to a
singly-linked list so that we can take advantage of structural sharing.

The "pending" queue, however, remains a circular list because it doesn't
need to be persistent.

This bug also affects the root fiber, which uses the same update queue
implementation and also acts like an error boundary.

It does not affect the hook update queue because they do not have any
notion of "captured" updates. So I've left it alone for now. However,
when we implement resuming, we will have to account for the same issue.

* Ensure base queue is a clone

When an error boundary captures an error, we append the error update
to the work-in-progress queue only so that if the render is aborted,
the error update is dropped.

Before appending to the queue, we need to make sure the queue is a
work-in-progress copy. Usually we clone the queue during
`processUpdateQueue`; however, if the base queue has lower priority
than the current render, we may have bailed out on the boundary fiber
without ever entering `processUpdateQueue`. So we need to lazily clone
the queue.

* Add warning to protect against refactor hazard

The hook queue does not have resuming or "captured" updates, but if
we ever add them in the future, we'll need to make sure we check if the
queue is forked before transfering the pending updates to them.
2020-03-11 11:53:45 -07:00
Sebastian Markbåge
b5c6dd2de5
Don't use Spread in DevTools Injection (#18277) 2020-03-11 10:58:25 -07:00
Sebastian Markbage
a463fef31b Revert "[React Native] Add getInspectorDataForViewAtPoint (#18233)"
This reverts commit bf351089a0.
2020-03-11 10:05:26 -07:00
Sebastian Markbåge
dc7eedae3c
Encode server rendered host components as array tuples (#18273)
This replaces the HTML renderer with instead resolving host elements into
arrays tagged with the react.element symbol. These turn into proper
React Elements on the client.

The symbol is encoded as the magical value "$". This has security implications
so this special value needs to remain escaped for other strings.

We could just encode the element as {$$typeof: "$", key: key props: props}
but that's a lot more bytes. So instead I encode it as:
["$", key, props] and then convert it back.

It would be nicer if React's reconciler could just accept these tuples.
2020-03-11 09:48:02 -07:00
Ricky
bf351089a0
[React Native] Add getInspectorDataForViewAtPoint (#18233) 2020-03-11 16:12:41 +00:00
Sebastian Markbåge
99d7371863
[Flight] Split Streaming from Relay Implemenation (#18260)
* Add ReactFlightServerConfig intermediate

This just forwards to the stream version of Flight which is itself forked
between Node and W3C streams.

The dom-relay goes directly to the Relay config though which allows it to
avoid the stream part of Flight.

* Separate streaming protocol into the Stream config

* Split streaming parts into the ReactFlightServerConfigStream

This decouples it so that the Relay implementation doesn't have to encode
the JSON to strings. Instead it can be fed the values as JSON objects and
do its own encoding.

* Split FlightClient into a basic part and a stream part

Same split as the server.

* Expose lower level async hooks to Relay

This requires an external helper file that we'll wire up internally.
2020-03-10 14:55:04 -07:00
Dominic Gannaway
160505b0ca
ReactDOM.useEvent: Add more scaffolding for useEvent hook (#18271) 2020-03-10 20:31:12 +00:00
Dominic Gannaway
a3bf668812
Flare: Fix listener upgrade bug (#18270) 2020-03-10 17:59:03 +00:00
Brian Vaughn
526c12f49e
Enable enableProfilerCommitHooks flag for FB (#18230) 2020-03-10 10:40:45 -07:00
Kerollos Magdy
9e5626cdde
Fix yarn warning on running 'yarn build-for-devtools' (#18232)
fixes #18231
2020-03-10 15:37:02 +00:00
Dominic Gannaway
29534252ad
ReactDOM.useEvent add flag and entry point (#18267) 2020-03-10 12:18:49 +00:00
Dominic Gannaway
704c8b0118
Fix Flow type for AnyNativeEvent (#18266) 2020-03-10 10:46:12 +00:00
Sebastian Markbåge
bdc5cc4635
Add Relay Flight Build (#18242)
* Rename to clarify that it's client-only

* Rename FizzStreamer to FizzServer for consistency

* Rename react-flight to react-client/flight

For consistency with react-server. Currently this just includes flight
but it could be expanded to include the whole reconciler.

* Add Relay Flight Build

* Rename ReactServerHostConfig to ReactServerStreamConfig

This will be the config specifically for streaming purposes.
There will be other configs for other purposes.
2020-03-07 11:23:30 -08:00
Sebastian Markbåge
7a1691cdff
Refactor Host Config Infra (getting rid of .inline*.js) (#18240)
* Require deep for reconcilers

* Delete inline* files

* Delete react-reconciler/persistent

This no longer makes any sense because it react-reconciler takes
supportsMutation or supportsPersistence as options. It's no longer based
on feature flags.

* Fix jest mocking

* Fix Flow strategy

We now explicitly list which paths we want to be checked by a renderer.
For every other renderer config we ignore those paths.

Nothing is "any" typed. So if some transitive dependency isn't reachable
it won't be accidentally "any" that leaks.
2020-03-06 16:20:42 -08:00
Sebastian Markbåge
238b57f0f7
[Blocks] Make it possible to have lazy initialized and lazy loaded Blocks (#18220)
* Lazify Blocks

Blocks now initialize lazily.

* Initialize Blocks eagerly in ChildFiber

This is for the case when it's a new Block that hasn't yet initialized.
We need to first initialize it to see what "render function" it resolves
to so that we can use that in our comparison.

* Remove extra import type line
2020-03-06 15:14:46 -08:00
Andrew Clark
235a6c4af6
Bugfix: Dropped effects in Legacy Mode Suspense (#18238)
* Failing: Dropped effects in Legacy Mode Suspense

* Transfer mounted effects on suspend in legacy mode

In legacy mode, a component that suspends bails out and commit in
its previous state. If the component previously had mounted effects,
we must transfer those to the work-in-progress so they don't
get dropped.
2020-03-06 11:10:01 -08:00
Andrew Clark
5fbb165602
Hard-code disableModulePatternComponents (#18239)
Hard-coding this until tests are fixed, to unblock master.
2020-03-06 11:09:36 -08:00
Brian Vaughn
cccba39f5b
Fixed broken anchor tag for patch release 2020-03-06 11:05:01 -08:00
Dan Abramov
562cf013db
Add a flag to disable module pattern components (#18133) 2020-03-06 18:46:32 +00:00
Andrew Clark
115cd12d9b
Add test run that uses www feature flags (#18234)
In CI, we run our test suite against multiple build configurations. For
example, we run our tests in both dev and prod, and in both the
experimental and stable release channels. This is to prevent accidental
deviations in behavior between the different builds. If there's an
intentional deviation in behavior, the test author must account
for them.

However, we currently don't run tests against the www builds. That's
a problem, because it's common for features to land in www before they
land anywhere else, including the experimental release channel.
Typically we do this so we can gradually roll out the feature behind
a flag before deciding to enable it.

The way we test those features today is by mutating the
`shared/ReactFeatureFlags` module. There are a few downsides to this
approach, though. The flag is only overridden for the specific tests or
test suites where you apply the override. But usually what you want is
to run *all* tests with the flag enabled, to protect against unexpected
regressions.

Also, mutating the feature flags module only works when running the
tests against source, not against the final build artifacts, because the
ReactFeatureFlags module is inlined by the build script.

Instead, we should run the test suite against the www configuration,
just like we do for prod, experimental, and so on. I've added a new
command, `yarn test-www`. It automatically runs in CI.

Some of the www feature flags are dynamic; that is, they depend on
a runtime condition (i.e. a GK). These flags are imported from an
external module that lives in www. Those flags will be enabled for some
clients and disabled for others, so we should run the tests against
*both* modes.

So I've added a new global `__VARIANT__`, and a new test command `yarn
test-www-variant`. `__VARIANT__` is set to false by default; when
running `test-www-variant`, it's set to true.

If we were going for *really* comprehensive coverage, we would run the
tests against every possible configuration of feature flags: 2 ^
numberOfFlags total combinations. That's not practical, though, so
instead we only run against two combinations: once with `__VARIANT__`
set to `true`, and once with it set to `false`. We generally assume that
flags can be toggled independently, so in practice this should
be enough.

You can also refer to `__VARIANT__` in tests to detect which mode you're
running in. Or, you can import `shared/ReactFeatureFlags` and read the
specific flag you can about. However, we should stop mutating that
module going forward. Treat it as read-only.

In this commit, I have only setup the www tests to run against source.
I'll leave running against build for a follow up.

Many of our tests currently assume they run only in the default
configuration, and break when certain flags are toggled. Rather than fix
these all up front, I've hard-coded the relevant flags to the default
values. We can incrementally migrate those tests later.
2020-03-06 09:29:05 -08:00
Christoph Nakazawa
4027f2a3b8
Break up require/import statements in strings (#18222) 2020-03-05 22:27:55 +00:00
Brian Vaughn
024a764310
Implemented Profiler onCommit() and onPostCommit() hooks (#17910)
* Implemented Profiler onCommit() and onPostCommit() hooks
* Added enableProfilerCommitHooks feature flag for commit hooks
* Moved onCommit and onPassiveCommit behind separate feature flag
2020-03-05 11:02:00 -08:00
Brian Vaughn
d35f8a5818
feat: honor displayName of context types (#18224)
* Revert "Revert "feat: honor displayName of context types (#18035)" (#18223)"

This reverts commit 3ee812e6b6.

* Add warning of displayName is set on the consumer

* dedupe warning
2020-03-05 10:13:52 -08:00
Dominic Gannaway
3ee812e6b6
Revert "feat: honor displayName of context types (#18035)" (#18223)
This reverts commit 45c172d948.
2020-03-05 15:58:04 +00:00
Dominic Gannaway
6a0efddd89
Modern Event System: export internal FB flag for testing (#18221) 2020-03-05 14:05:00 +00:00
Sunil Pai
21b713b9fd
Updated React Native home URL (#18218) 2020-03-05 13:15:46 +00:00
Dominic Gannaway
60b11f6c1b
Modern Event System: Support nested portal/root boundaries (#18201) 2020-03-05 09:00:13 +00:00
Sebastian Markbåge
fa03206ee4
Remove _ctor field from Lazy components (#18217)
* This type is all wrong and nothing cares because it's all any

* Refine Flow types of Lazy Components

We can type each condition.

* Remove _ctor field from Lazy components

This field is not needed because it's only used before we've initialized,
and we don't have anything else to store before we've initialized.

* Check for _ctor in case it's an older isomorphic that created it

We try not to break across minors but it's no guarantee.

* Move types and constants from shared to isomorphic

The "react" package owns the data structure of the Lazy component. It
creates it and decides how any downstream renderer may use it.

* Move constants to shared

Apparently we can't depend on react/src/ because the whole package is
considered "external" as far as rollup is concerned.
2020-03-04 20:52:48 -08:00
Dominic Gannaway
2fe0fbb05e
Use accumulateTwoPhaseDispatchesSingle directly (#18203) 2020-03-05 00:04:27 +00:00
Dominic Gannaway
503fd82b42
Modern Event System: Add support for internal FB Primer (#18210) 2020-03-04 23:41:59 +00:00