Commit Graph
791 Commits
Author SHA1 Message Date
Dominic GannawayandGitHub c804f9aebb ReactDOM.useEvent: wire to event system to the hook (#18304) 2020-03-16 21:46:17 +00:00
Dominic GannawayandGitHub 0705b7282f Refine event system types + pass through priority (#18305) 2020-03-13 17:57:17 +00:00
Dominic GannawayandGitHub 45d26f6edb Remove un-used function arg (#18303) 2020-03-13 14:16:12 +00:00
Dominic GannawayandGitHub 2a7cd58956 ReactDOM.useEvent: Add DOM host event listener logic (#18292) 2020-03-12 22:41:33 +00:00
Dominic GannawayandGitHub d3ec42020d Address feedback for accumulateTwoPhaseListeners (#18289) 2020-03-12 21:48:29 +00:00
Dominic GannawayandGitHub 99d271228d ReactDOM.useEvent: more scaffolding changes (#18282) 2020-03-12 09:12:06 +00:00
Dominic GannawayandGitHub 8b155d2613 Flow type ReactDOMComponentTree (#18280) 2020-03-11 19:38:23 +00:00
Brian VaughnandGitHub 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 GannawayandGitHub 30a998debf ModernEventSystem: refactor accumulateTwoPhaseListeners (#18274) 2020-03-11 18:55:01 +00:00
Dominic GannawayandGitHub 160505b0ca ReactDOM.useEvent: Add more scaffolding for useEvent hook (#18271) 2020-03-10 20:31:12 +00:00
Dominic GannawayandGitHub a3bf668812 Flare: Fix listener upgrade bug (#18270) 2020-03-10 17:59:03 +00:00
Dominic GannawayandGitHub 29534252ad ReactDOM.useEvent add flag and entry point (#18267) 2020-03-10 12:18:49 +00:00
Sebastian MarkbågeandGitHub 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ågeandGitHub 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
Andrew ClarkandGitHub 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
Dominic GannawayandGitHub 60b11f6c1b Modern Event System: Support nested portal/root boundaries (#18201) 2020-03-05 09:00:13 +00:00
Sebastian MarkbågeandGitHub 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 GannawayandGitHub 2fe0fbb05e Use accumulateTwoPhaseDispatchesSingle directly (#18203) 2020-03-05 00:04:27 +00:00
Dominic GannawayandGitHub 503fd82b42 Modern Event System: Add support for internal FB Primer (#18210) 2020-03-04 23:41:59 +00:00
Dominic GannawayandGitHub 83c3ed290c Fix instanceContainsElem bug from typo (#18213) 2020-03-04 19:53:16 +00:00
Dominic GannawayandGitHub 8e6a08ea4f Modern Event System: add plugin handling and forked paths (#18195) 2020-03-03 14:37:06 +00:00
Dominic GannawayandGitHub 62861bbcc7 More event system cleanup and scaffolding (#18179) 2020-03-02 10:59:07 +00:00
Dan AbramovandGitHub d72700ff5a Remove runtime dependency on prop-types (#18127)
* Remove runtime dep on prop-types

* Fix test
2020-02-28 01:21:54 +00:00
Dan AbramovandGitHub 849e8328b5 Remove unnecessary warnings (#18135) 2020-02-27 02:14:30 +00:00
Sebastian MarkbågeandGitHub f9c0a45441 Convert the rest of react-dom and react-test-renderer to Named Exports (#18145)
Nothing interesting here except that ReactShallowRenderer currently exports
a class with a static method instead of an object.

I think the public API is probably just meant to be createRenderer but
currently the whole class is exposed. So this means that we have to keep
it as default export. We could potentially also expose a named export for
createRenderer but that's going to cause compatibility issues.

So I'm just going to make that export default.

Unfortunately Rollup and Babel (which powers Jest) disagree on how to
import this. So to make it work I had to move the jest tests to imports.

This doesn't work with module resetting. Some tests weren't doing that
anyway and the rest is just testing ReactShallowRenderer so meh.
2020-02-26 18:04:32 -08:00
Steve HarrisonandGitHub f3ecd56bea Fixed a spelling mistake in a comment. (#18119) 2020-02-25 21:01:08 -08:00
Sebastian MarkbågeandGitHub 60016c448b Export React as Named Exports instead of CommonJS (#18106)
* Add options for forked entry points

We currently fork .fb.js entry points. This adds a few more options.

.modern.fb.js - experimental FB builds
.classic.fb.js - stable FB builds
.fb.js - if no other FB build, use this for FB builds
.experimental.js - experimental builds
.stable.js - stable builds
.js - used if no other override exists

This will be used to have different ES exports for different builds.

* Switch React to named exports

* Export named exports from the export point itself

We need to re-export the Flow exported types so we can use them in our code.

We don't want to use the Flow types from upstream since it doesn't have the non-public APIs that we have.

This should be able to use export * but I don't know why it doesn't work.

This actually enables Flow typing of React which was just "any" before.
This exposed some Flow errors that needs fixing.

* Create forks for the react entrypoint

None of our builds expose all exports and they all differ in at least one
way, so we need four forks.

* Set esModule flag to false

We don't want to emit the esModule compatibility flag on our CommonJS
output. For now we treat our named exports as if they're CommonJS.

This is a potentially breaking change for scheduler (but all those apis
are unstable), react-is and use-subscription. However, it seems unlikely
that anyone would rely on this since these only have named exports.

* Remove unused Feature Flags

* Let jest observe the stable fork for stable tests

This lets it do the negative test by ensuring that the right tests fail.

However, this in turn will make other tests that are not behind
__EXPERIMENTAL__ fail. So I need to do that next.

* Put all tests that depend on exports behind __EXPERIMENTAL__

Since there's no way to override the exports using feature flags
in .intern.js anymore we can't use these APIs in stable.

The tradeoff here is that we can either enable the negative tests on
"stable" that means experimental are expected to fail, or we can disable
tests on stable. This is unfortunate since some of these APIs now run on
a "stable" config at FB instead of the experimental.

* Switch ReactDOM to named exports

Same strategy as React.

I moved the ReactDOMFB runtime injection to classic.fb.js

Since we only fork the entrypoint, the `/testing` entrypoint needs to
be forked too to re-export the same things plus `act`. This is a bit
unfortunate. If it becomes a pattern we can consider forking in the
module resolution deeply.

fix flow

* Fix ReactDOM Flow Types

Now that ReactDOM is Flow type checked we need to fix up its types.

* Configure jest to use stable entry for ReactDOM in non-experimental

* Remove additional FeatureFlags that are no longer needed

These are only flagging the exports and no implementation details so we
can control them fully through the export overrides.
2020-02-25 13:54:27 -08:00
Sebastian MarkbågeandGitHub ccab494738 Move type DOMContainer to HostConfig (#18112)
Exports from ReactDOM represents React's public API. This include types
exported by React. At some point we'll start building Flow types from
these files.

The duplicate name between DOMContainer and Container seems confusing too
since it was used in the same files even though they're the same.
2020-02-24 08:57:48 -08:00
Sebastian MarkbågeandGitHub 09348798a9 Codemod to import * as React from "react"; (#18102)
* import * as React from "react";

This is the correct way to import React from an ES module since the ES
module will not have a default export. Only named exports.

* import * as ReactDOM from "react-dom"
2020-02-21 19:45:20 -08:00
Sebastian MarkbågeandGitHub 2c4221ce8b Change string refs in function component message (#18031)
This should refer to string refs specifically. The forwardRef part doesn't
make any sense in this case. I think this was just an oversight.
2020-02-21 10:12:34 -08:00
Dominic GannawayandGitHub 3f85d53ca6 Further pre-requisite changes to plugin event system (#18083) 2020-02-20 00:46:03 +00:00
Dominic GannawayandGitHub 1000f6135e Add container to event listener signature (#18075) 2020-02-19 18:00:57 +00:00
Dominic GannawayandGitHub 4912ba31e3 Add modern event system flag + rename legacy plugin module (#18073) 2020-02-19 14:36:39 +00:00
Dominic GannawayandGitHub 1a6d8179b6 [react-interactions] Ensure onBeforeBlur fires for hideInstance (#18064) 2020-02-18 18:50:38 +00:00
Dominic GannawayandGitHub f48a5e64e8 Further cleanup of plugin event system (#18056) 2020-02-18 13:31:59 +00:00
Dominic GannawayandGitHub 9def56ec0e Refactor DOM plugin system to single module (#18025) 2020-02-14 08:10:42 +00:00
Dan AbramovandGitHub 8777b44e98 Add Modern WWW build (#18028)
* Build both stable and experimental WWW builds

* Flip already experimental WWW flags to true

* Remove FB-specific internals from modern FB builds

We think we're not going to need these.

* Disable classic features in modern WWW builds

* Disable legacy ReactDOM API for modern WWW build

* Don’t include user timing in prod

* Fix bad copy paste and add missing flags to test renderer

* Add testing WWW feature flag file

We need it because WWW has a different meaning of experimental now.
2020-02-13 20:33:53 +00:00
Dan AbramovandGitHub a607ea4c42 Remove getIsHydrating (#18019) 2020-02-12 01:01:29 +00:00
Dominic GannawayandGitHub df5faddcc2 Refactor commitPlacement to recursively insert nodes (#17996) 2020-02-10 23:38:24 +00:00
Dan AbramovandGitHub ab7b83a924 Stop exposing some internals on FB build (#18011) 2020-02-10 19:52:27 +00:00
Sophie AlpertandGitHub 4f71f25a34 Re-enable shorthand CSS property collision warning (#18002)
Originally added in https://github.com/facebook/react/pull/14181; disabled in https://github.com/facebook/react/pull/14245. Intention was to enable it in React 16.7 but we forgot.
2020-02-10 11:42:11 +00:00
Andrew ClarkandGitHub 9dba218d93 [Mock Scheduler] Mimic browser's advanceTime (#17967)
The mock Scheduler that we use in our tests has its own fake timer
implementation. The `unstable_advanceTime` method advances the timeline.

Currently, a call to `unstable_advanceTime` will also flush any pending
expired work. But that's not how it works in the browser: when a timer
fires, the corresponding task is added to the Scheduler queue. However,
we will still wait until the next message event before flushing it.

This commit changes `unstable_advanceTime` to more closely resemble the
browser behavior, by removing the automatic flushing of expired work.

```js
// Before this commit
Scheduler.unstable_advanceTime(ms);

// Equivalent behavior after this commit
Scheduler.unstable_advanceTime(ms);
Scheduler.unstable_flushExpired();
```

The general principle is to prefer separate APIs for scheduling tasks
and flushing them.

This change does not affect any public APIs. `unstable_advanceTime` is
only used by our own test suite. It is not used by `act`.

However, we may need to update tests in www, like Relay's.
2020-02-04 11:35:21 -08:00
Alfredo GranjaandGitHub 812277dab6 Fix onMouseEnter is fired on disabled buttons (#17675) 2020-02-04 14:56:55 +00:00
Sunil PaiandGitHub 3e9251d605 make testing builds for React/ReactDOM (#17915)
This PR introduces adds `react/testing` and `react-dom/testing`.
- changes infra to generate these builds
- exports act on ReactDOM in these testing builds
- uses the new test builds in fixtures/dom

In the next PR -

- I'll use the new builds for all our own tests
- I'll replace usages of TestUtils.act with ReactDOM.act.
2020-02-03 23:31:31 +00:00
Sebastian MarkbågeandGitHub ace9e8134c Simplify Continuous Hydration Targets (#17952)
* Simplify Continuous Hydration Targets

Let's use a constant priority for this. This helps us avoid restarting
a render when switching targets and simplifies the model.

The downside is that now we're not down-prioritizing the previous hover
target. However, we think that's ok because it'll only do one level too
much and then stop.

* Add test meant to show why it's tricky to merge both hydration levels

Having both levels co-exist works. However, if we deprioritize hydration
using a single level, we might deprioritize the wrong thing.

This adds a test that catches it if we ever try a naive deprioritization
in the future.

It also tests that we don't down-prioritize if we're changing the hover
in the middle of doing continuous priority work.
2020-02-03 12:47:14 -08:00
EvyatarandGitHub 9944bf27fb Add version property to ReactDOM (#15780) 2020-02-03 11:19:04 -08:00
Deniz SusmanandGitHub 00745b053f Typo fix (#17946) 2020-01-31 14:51:43 -08:00
Sebastian MarkbågeandGitHub e98797f7b9 Fix Event Replaying in Flare by Eagerly Adding Active Listeners (#17933)
* Add test of Event Replaying using Flare

* Fix Event Replaying in Flare by Eagerly Adding Active Listeners

This effectively reverts part of https://github.com/facebook/react/pull/17513
2020-01-30 09:32:41 -08:00
Dominic GannawayandGitHub 1662035852 Ensure createRoot warning parity with ReactDOM.render (#17937) 2020-01-30 17:17:42 +00:00
Dominic GannawayandGitHub b2382a7150 Add ReactDOM.unstable_renderSubtreeIntoContainer warning flag (#17936) 2020-01-30 11:56:04 +00:00