Commit Graph
923 Commits
Author SHA1 Message Date
Sebastian MarkbågeandGitHub 96e5d57d2f Move some files out of /shared and rename to upper case (#18363)
* Rename lower case isomorphic default exports modules to upper case named exports

We're somewhat inconsistent here between e.g. ReactLazy and memo.

Let's pick one.

This also moves the responder, fundamental, scope creators from shared
since they're isomorphic and same as the other creators.

* Move some files that are specific to the react-reconciler from shared

Individual renderers are allowed to deep require into the reconciler.

* Move files specific to react-dom from shared

react-interactions is right now dom specific (it wasn't before) so we can
type check it together with other dom stuff. Avoids the need for
a shared ReactDOMTypes to be checked by RN for example.

* Move ReactWorkTags to the reconciler

* Move createPortal to export from reconciler

Otherwise Noop can't access it since it's not allowed deep requires.
2020-03-21 15:22:01 -07:00
Dominic GannawayandGitHub ba51aca0ee ReactDOM.useEvent: add EventTarget support (#18355)
* ReactDOM.useEvent: add support for all EventTarget types
2020-03-20 18:31:47 +00:00
Dominic GannawayandGitHub d7ea3a9602 ReactDOM.useEvent: support custom types (#18351)
* ReactDOM.useEvent: support custom types
2020-03-20 14:45:33 +00:00
Luna RuanandGitHub 2d3e596e0c fix string ref cannot be auto converted warning for React.jsxDEV (#18354)
The string ref cannot be auto converted warning was using the wrong _self. This diff fixes this so it is now using the correct __self
2020-03-19 23:47:53 -07:00
Dominic GannawayandGitHub bb25737c8e ModernEventSystem: fix event replaying (#18346)
* ModernEventSystem: fix event replaying
2020-03-19 20:44:38 +00:00
Dominic GannawayandGitHub 9d264f557a ModernEventSystem: refine Flow types (#18349) 2020-03-19 20:25:52 +00:00
Andrew ClarkandGitHub 32cc2cf879 Revert accidental changes to package.json (#18348)
The publish script was written before we switched to running patch
releases out-of-band, so when updating the local package.json version
numbers, it accidentally reverted other changes that have landed to
master since 16.13 was released.
2020-03-19 13:16:37 -07:00
Andrew Clark a8669ac2cd Update package.jsons for 16.13.1 patch relase 2020-03-19 12:58:31 -07:00
Dominic GannawayandGitHub 32de0e40e0 Modern Event System: refactor legacy FB support logic (#18336) 2020-03-19 13:22:36 +00:00
Dan AbramovandGitHub 0d5a4639c1 Stop exposing ReactDOMComponentTree from FB builds (#18338) 2020-03-18 20:35:58 +00:00
Sebastian MarkbågeandGitHub 54d5e2629a Don't use EventListener Fork in Modern WWW Builds (#18333)
* Move unsubscribe fork to EventListener

That way we can statically compile out more of these indirections.

* Don't use the EventListener fork for Modern WWW builds
2020-03-18 13:13:50 +00:00
Dominic GannawayandGitHub 87b52eb3f9 React Event System: Refactor ElementListenerMap for upgrading (#18308) 2020-03-18 00:15:50 +00:00
Dan AbramovandGitHub d9d31046de Don't fire the render phase update warning for class lifecycles (#18330)
* Change the warning to not say "function body"

This warning is more generic and may happen with class components too.

* Dedupe by the rendering component

* Don't warn outside of render
2020-03-18 00:07:14 +00:00
e8febb1d8b test(getComponentName): Increase test coverage (#18149)
Co-authored-by: Brian Vaughn <[email protected]>
2020-03-17 14:47:24 -07:00
Dan AbramovandGitHub 862c4a0958 Don't support older isomorphic React with newer renderers (#18329)
* Don't support older isomorphic React with newer renderers

* Remove the lazy hack
2020-03-17 19:30:10 +00:00
Dominic GannawayandGitHub 6053e7db18 useEvent: Small tweaks and changes (#18328) 2020-03-17 15:32:26 +00:00
Dominic GannawayandGitHub 251bdbfbab ReactDOM.useEvent: wire to event system to the hook (#18304) 2020-03-16 21:46:17 +00:00
Dominic GannawayandGitHub b03108e3a1 Refine event system types + pass through priority (#18305) 2020-03-13 17:57:17 +00:00
Dominic GannawayandGitHub 71a1cb3539 Remove un-used function arg (#18303) 2020-03-13 14:16:12 +00:00
Dominic GannawayandGitHub c90976d127 ReactDOM.useEvent: Add DOM host event listener logic (#18292) 2020-03-12 22:41:33 +00:00
Dominic GannawayandGitHub 5e0aedd107 Address feedback for accumulateTwoPhaseListeners (#18289) 2020-03-12 21:48:29 +00:00
Dominic GannawayandGitHub 43935eb2ea ReactDOM.useEvent: more scaffolding changes (#18282) 2020-03-12 09:12:06 +00:00
Dominic GannawayandGitHub 094928135a Flow type ReactDOMComponentTree (#18280) 2020-03-11 19:38:23 +00:00
Brian VaughnandGitHub 7d06efcece 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 0fe9ea7c50 ModernEventSystem: refactor accumulateTwoPhaseListeners (#18274) 2020-03-11 18:55:01 +00:00
Dominic GannawayandGitHub b4b497e930 ReactDOM.useEvent: Add more scaffolding for useEvent hook (#18271) 2020-03-10 20:31:12 +00:00
Dominic GannawayandGitHub 7fc926c50d Flare: Fix listener upgrade bug (#18270) 2020-03-10 17:59:03 +00:00
Dominic GannawayandGitHub 88d0b699ae ReactDOM.useEvent add flag and entry point (#18267) 2020-03-10 12:18:49 +00:00
Sebastian MarkbågeandGitHub 37e89f7e31 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 46e7629f67 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 5b304d2d47 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 b4e066ebc7 Modern Event System: Support nested portal/root boundaries (#18201) 2020-03-05 09:00:13 +00:00
Sebastian MarkbågeandGitHub 9ee3817448 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 cc0b613300 Use accumulateTwoPhaseDispatchesSingle directly (#18203) 2020-03-05 00:04:27 +00:00
Dominic GannawayandGitHub 20923af1dc Modern Event System: Add support for internal FB Primer (#18210) 2020-03-04 23:41:59 +00:00
Dominic GannawayandGitHub 31aac8c817 Fix instanceContainsElem bug from typo (#18213) 2020-03-04 19:53:16 +00:00
Dominic GannawayandGitHub 5a7c46fb6d Modern Event System: add plugin handling and forked paths (#18195) 2020-03-03 14:37:06 +00:00
Dominic GannawayandGitHub 4bb40c4003 More event system cleanup and scaffolding (#18179) 2020-03-02 10:59:07 +00:00
Dan AbramovandGitHub 4e59e9ba18 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 aebef903f0 Remove unnecessary warnings (#18135) 2020-02-27 02:14:30 +00:00
Sebastian MarkbågeandGitHub 9042dd08a4 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
Sunil PaiandGitHub 73217149ad update version numbers for 16.13 (#18143)
also includes a bugfix when downloading error codes from circleci.
2020-02-26 20:33:29 +00:00
Steve HarrisonandGitHub 00a963e5e6 Fixed a spelling mistake in a comment. (#18119) 2020-02-25 21:01:08 -08:00
Sebastian MarkbågeandGitHub ad1819c135 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 119bc7758f 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 33fea4647c 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 5adcd7cc1f 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 1c8c734da3 Further pre-requisite changes to plugin event system (#18083) 2020-02-20 00:46:03 +00:00
Dominic GannawayandGitHub 5e62b9eae3 Add container to event listener signature (#18075) 2020-02-19 18:00:57 +00:00
Dominic GannawayandGitHub b961d8bc0c Add modern event system flag + rename legacy plugin module (#18073) 2020-02-19 14:36:39 +00:00