Commit Graph
10319 Commits
Author SHA1 Message Date
Andrew ClarkandGitHub bc1a29df20 Jest + test renderer helpers for concurrent mode (#13751)
* Jest + test renderer helpers for concurrent mode

Most of our concurrent React tests use the noop renderer. But most
of those tests don't test the renderer API, and could instead be
written with the test renderer. We should switch to using the test
renderer whenever possible, because that's what we expect product devs
and library authors to do. If test renderer is sufficient for writing
most React core tests, it should be sufficient for others, too. (The
converse isn't true but we should aim to dogfood test renderer as much
as possible.)

This PR adds a new package, jest-react (thanks @cpojer). I've moved
our existing Jest matchers into that package and added some new ones.

I'm not expecting to figure out the final API in this PR. My goal is
to land something good enough that we can start dogfooding in www.

TODO: Continue migrating Suspense tests, decide on better API names

* Add additional invariants to prevent common errors

- Errors if user attempts to flush when log of yields is not empty
- Throws if argument passed to toClearYields is not ReactTestRenderer

* Better method names

- toFlushAll -> toFlushAndYield
- toFlushAndYieldThrough ->
- toClearYields -> toHaveYielded

Also added toFlushWithoutYielding

* Fix jest-react exports

* Tweak README
2018-10-03 18:37:41 -06:00
HeavenandAndrew Clark 7ba1e21dbc Remove unreachable code (#13762) 2018-10-03 18:03:01 -06:00
Brian VaughnandGitHub 7ffdcc9587 Always warn about legacy context within StrictMode tree (#13760) 2018-10-03 08:40:45 -07:00
Maksim MarkelovandDan Abramov 193a108419 UMD react-cache build (#13761) 2018-10-03 15:09:17 +01:00
Andrew Clark aecdca7e29 Fix simple-cache-provider import that I missed 2018-10-02 00:50:33 -06:00
Joe CortopassiandDan Abramov 97ca6ff8fa --save is no longer needed (#13756)
`--save` is on by default as of [npm 5](https://blog.npmjs.org/post/161081169345/v500), and `npm install aphrodite` is functionally equivalent to `npm install --save aphrodite` now
2018-10-01 19:15:11 +01:00
Andrew ClarkandGitHub fe203cb6e1 Rename simple-cache-provider to react-cache (#13755) 2018-10-01 09:07:40 -06:00
Brian VaughnandGitHub 4ac81d48ff Removed extra typeof checks for contextType.unstable_read (#13736) 2018-09-28 13:12:26 -07:00
Brian VaughnandGitHub b72d3d4d60 Enable getDerivedStateFromError (#13746)
* Removed the enableGetDerivedStateFromCatch feature flag (aka permanently enabled the feature)
* Forked/copied ReactErrorBoundaries to ReactLegacyErrorBoundaries for testing componentDidCatch
* Updated error boundaries tests to apply to getDerivedStateFromCatch
* Renamed getDerivedStateFromCatch -> getDerivedStateFromError
* Warn if boundary with only componentDidCatch swallows error
* Fixed a subtle reconciliation bug with render phase error boundary
2018-09-28 13:05:01 -07:00
Andrew ClarkandGitHub 639bfc5dd4 pure (#13748)
* pure

A higher-order component version of the `React.PureComponent` class.
During an update, the previous props are compared to the new props. If
they are the same, React will skip rendering the component and
its children.

Unlike userspace implementations, `pure` will not add an additional
fiber to the tree.

The first argument must be a functional component; it does not work
with classes.

`pure` uses shallow comparison by default, like `React.PureComponent`.
A custom comparison can be passed as the second argument.

Co-authored-by: Andrew Clark <[email protected]>
Co-authored-by: Sophie Alpert <[email protected]>

* Warn if first argument is not a functional component
2018-09-27 15:25:38 -07:00
Andrew Clark 75d2bd0846 [scheduler] Improve naive fallback version used in non-DOM environments
Added some tests for the non-DOM version of Scheduler that is used
as a fallback, e.g. Jest. The tests use Jest's fake timers API:

- `jest.runAllTimers(ms)` flushes all scheduled work, as expected
- `jest.advanceTimersByTime(ms)` flushes only callbacks that expire
within the given milliseconds.

These capabilities should be sufficient for most product tests. Because
jest's fake timers do not override performance.now or Date.now, we
assume time is constant. This means Scheduler's internal time will not
be aligned with other code that reads from `performance.now`. For finer
control, the user can override `window._sched` like we do in our tests.
We will likely publish a Jest package that has this built in.
2018-09-26 20:25:21 -07:00
Timothy YungandGitHub 10ff218ba8 Revise AttributeType React Native Flow Type (#13737) 2018-09-26 14:40:57 -07:00
Dominic GannawayandGitHub e9ab29e0f6 Rename AsyncMode -> ConcurrentMode (#13732)
* Rename AsyncMode -> ConcurrentMode
2018-09-26 17:13:02 +01:00
Dominic GannawayandGitHub f1b22c1c3a Ensure "addEventListener" exists on "window" for "scheduler" package (#13731)
* Ensure addEventListener exists on "window"
2018-09-26 13:38:56 +01:00
Brian VaughnandGitHub b37d245624 Added a PureComponent contextType test (#13729) 2018-09-25 17:28:33 -07:00
Brian VaughnandGitHub 83ad30bda6 Support class component static contextType attribute (#13728)
* Support class component static contextType attribute
2018-09-25 15:49:46 -07:00
Andrew ClarkandGitHub db1fd94244 [scheduler] Priority levels, continuations, and wrapped callbacks (#13720)
All of these features are based on features of React's internal
scheduler. The eventual goal is to lift as much as possible out of the
React internals into the Scheduler package.

Includes some renaming of existing methods.

- `scheduleWork` is now `scheduleCallback`
- `cancelScheduledWork` is now `cancelCallback`


Priority levels
---------------

Adds the ability to schedule callbacks at different priority levels.
The current levels are (final names TBD):

- Immediate priority. Fires at the end of the outermost currently
executing (similar to a microtask).
- Interactive priority. Fires within a few hundred milliseconds. This
should only be used to provide quick feedback to the user as a result
of an interaction.
- Normal priority. This is the default. Fires within several seconds.
- "Maybe" priority. Only fires if there's nothing else to do. Used for
prerendering or warming a cache.

The priority is changed using `runWithPriority`:

```js
runWithPriority(InteractivePriority, () => {
  scheduleCallback(callback);
});
```


Continuations
-------------

Adds the ability for a callback to yield without losing its place
in the queue, by returning a continuation. The continuation will have
the same expiration as the callback that yielded.


Wrapped callbacks
-----------------

Adds the ability to wrap a callback so that, when it is called, it
receives the priority of the current execution context.
2018-09-25 15:11:42 -07:00
Brian NgandDan Abramov 3944c5f577 Bump babel-eslint and remove flow supressions (#13727) 2018-09-25 22:48:31 +01:00
Brian VaughnandGitHub 93edf6a49f Interaction tracking ref-counting bug fixes (WIP) (#13590)
* Added new (failing) suspense+interaction tests
* Add new tracing+suspense test harness fixture
* Refactored interaction tracing to fix ref counting bug
2018-09-25 09:27:41 -07:00
Sergei StartsevandDan Abramov 999883c854 Restore global window.event after event dispatching (#13688) (#13697) 2018-09-25 16:24:23 +01:00
HeavenandAndrew Clark 580cbc7ee5 Remove redundant logic (#13502) 2018-09-24 17:59:29 -07:00
PhilippandGitHub df71ce072a Add closing parenthesis (#13712)
I’ve first seen it in the [releases view](https://github.com/facebook/react/releases/tag/v16.5.2) and fixed it there as well.
2018-09-23 12:36:47 +02:00
Maksim MarkelovandDan Abramov be3edc18d0 Fix circular dependency in TracingSubscriptions (#13689) 2018-09-19 18:48:32 +01:00
HeavenandDan Abramov 743bab707e Clarify comment (#13684)
* fix comment typo

* Update Scheduler.js
2018-09-19 13:14:32 +01:00
Dan 03141fbf57 Remove some old files from stats 2018-09-19 01:36:31 +01:00
Dan AbramovandGitHub f213e690bb Rename schedule to scheduler (#13683) 2018-09-19 01:26:28 +01:00
Brian Vaughn 70454b4c7c Added another bullet to the CHANGELOG 2018-09-18 12:45:31 -07:00
Brian Vaughn b2d0b92606 Rename 'Schedule' header -> 'Schedule (Experimental)' 2018-09-18 12:41:14 -07:00
Brian Vaughn 591d57e5e0 16.5.2 CHANGELOG 2018-09-18 12:39:32 -07:00
Brian Vaughn 671d32fec2 Update bundle sizes for 16.5.2 release 2018-09-18 11:30:50 -07:00
Brian Vaughn edd1b64231 Update error codes for 16.5.2 release 2018-09-18 11:30:50 -07:00
Brian Vaughn 94916e4c79 Updating package versions for release 16.5.2 2018-09-18 11:24:33 -07:00
Brian Vaughn 28ebb62640 Revert "Updating package versions for release 16.6.0-alpha.0"
This reverts commit 31b9c40bd7.
2018-09-18 11:00:13 -07:00
Brian Vaughn 64ca620f19 Revert "Updating dependencies for react-noop-renderer"
This reverts commit ea58cabf25.
2018-09-18 11:00:09 -07:00
Brian Vaughn b334069abd Revert "Update error codes for 16.6.0-alpha.0 release"
This reverts commit d51f875f28.
2018-09-18 11:00:04 -07:00
Brian Vaughn 893fc1c0f6 Revert "Update bundle sizes for 16.6.0-alpha.0 release"
This reverts commit c497fabbe9.
2018-09-18 10:59:57 -07:00
HeavenandNathan Hunzaker 535e95edd7 Kepp calling peformWork consistent (#13596) 2018-09-18 07:48:18 -07:00
Brian Vaughn c497fabbe9 Update bundle sizes for 16.6.0-alpha.0 release 2018-09-17 15:05:46 -07:00
Brian Vaughn d51f875f28 Update error codes for 16.6.0-alpha.0 release 2018-09-17 15:05:46 -07:00
Brian Vaughn ea58cabf25 Updating dependencies for react-noop-renderer 2018-09-17 14:59:57 -07:00
Brian Vaughn 31b9c40bd7 Updating package versions for release 16.6.0-alpha.0 2018-09-17 14:59:57 -07:00
Dan AbramovandGitHub 9f316a6914 Revert "Do not bind topLevelType to dispatch" (#13674)
* Revert "Do not bind topLevelType to dispatch (#13618)"

This reverts commit 7a25466019.
2018-09-17 18:43:16 +01:00
Sam KvaleandBrian Vaughn 8c17f768f8 docs(changelog): Fix misspelling (#13663)
dangerouslySetInnerHTML was misspelled dangerousSetInnerHTML
2018-09-15 08:16:58 -07:00
Alexey RaspopovandDan Abramov a8947339ec remove flow typings from Schedule.js (#13662) 2018-09-15 03:55:23 +01:00
Nathan HunzakerandGitHub 9e255d43d4 Resubmit: Fix updateWrapper causing re-render textarea, even though their data (#13643)
* fix updateWrapper causing re-render textarea, even though their data has not changed

* fix updateWrapper causing re-render textarea, even though their data, prettier-all

* minor changes to updateWrapper, add test
2018-09-14 16:09:07 -07:00
Nathan HunzakerandGitHub 7a25466019 Do not bind topLevelType to dispatch (#13618)
* Do not bind topLevelType to dispatch

A previous change made it such that all top level event types
correspond to their associated native event string values. This commit
eliminates the .bind attached to dispatch and fixes a related flow
type.

* Add note about why casting event.type to a topLevelType is safe

* Move interactiveUpdates comment to point of assignment
2018-09-14 16:08:37 -07:00
Andrew ClarkandGitHub ebf80a4217 [schedule] Refactor Schedule, remove React-isms (#13582)
* Refactor Schedule, remove React-isms

Once the API stabilizes, we will move Schedule this into a separate
repo. To promote adoption, especially by projects outside the React
ecosystem, we'll remove all React-isms from the source and keep it as
simple as possible:

- No build step.
- No static types.
- Everything is in a single file.

If we end up needing to support multiple targets, like CommonJS and ESM,
we can still avoid a build step by maintaining two copies of the same
file, but with different exports.

This commit also refactors the implementation to split out the DOM-
specific parts (essentially a requestIdleCallback polyfill). Aside from
the architectural benefits, this also makes it possible to write host-
agnostic tests. If/when we publish a version of Schedule that targets
other environments, like React Native, we can run these same tests
across all implementations.

* Edits in response to Dan's PR feedback
2018-09-14 14:05:55 -07:00
Jérôme SteunouandDan Abramov 2e515d67a0 Fix some iframe edge cases (#13650)
Should fix #13648 by fallback on `window` when `document.defaultView` does not exists anymore
2018-09-14 16:44:14 +01:00
Brian VaughnandGitHub d76bf0d21a Add UMD production+profiling entry points (#13642)
* Added UMD_PROFILING type to react-dom and scheduling package. Added UMD shim to schedule package.
* Added new schedule umd prod+prof bundle to API test
2018-09-13 17:44:08 -07:00
HeavenandNathan Hunzaker 477fb28cdf Fix test comment typo (#13568) 2018-09-13 17:33:16 -07:00