Commit Graph
13509 Commits
Author SHA1 Message Date
5d8a405ecd Add flow to SyntheticEvent (#19564)
* Add flow to SyntheticEvent

* Minimal implementation of known and unknown synthetic events

* less casting

* Update EnterLeaveEventPlugin.js

Co-authored-by: Dan Abramov <[email protected]>
2020-08-19 14:16:48 +01:00
Julien GilliandGitHub 24b8c2a66d provide profiling bundle for react-reconciler (#19559) 2020-08-19 14:11:27 +01:00
Toru KobayashiandGitHub 4a0f7acac2 refactor: remove unnecessary return statements (#19625) 2020-08-19 14:10:41 +01:00
Sam MarksandGitHub 9a83027101 fix: property list values should show whitespace (#19640) 2020-08-19 08:50:46 -04:00
Brian VaughnandGitHub 9a72ba28c4 Add missing param to safelyCallDestroy() (#19638) 2020-08-18 12:02:04 -04:00
ᴜɴвʏтᴇandGitHub 5fcd0a7b81 fix: open two same tabs on firefox (#19632)
close #19629
2020-08-18 10:17:00 -04:00
Luna RuanandGitHub 27749e0c82 change destroy to safelyCallDestroy (#19605)
We use safelyCallDestroy for commitUnmount and passive effects unmounts but we call destroy directly in commitHookEffectListUnmount (AKA layout effects unmounts because we don't use this anywhere else). This PR changes the direct destroy call to safelyCallDestroy for consistency
2020-08-17 17:32:50 -07:00
Brian VaughnandGitHub 367c24ea79 Always skip unmounted/unmounting error boundaries (#19627)
The behavior of error boundaries for passive effects that throw during cleanup was recently changed so that React ignores boundaries which are also unmounting in favor of still-mounted boundaries. This commit implements that same behavior for layout effects (useLayoutEffect, componentWillUnmount, and ref-detachment).

The new, skip-unmounting-boundaries behavior is behind a feature flag (`skipUnmountedBoundaries`).
2020-08-17 15:01:06 -04:00
Timothy YungandGitHub 2a00a30b07 Append text string to <Text> error message (#19581)
* Append text string to <Text> error message

* Truncate text in <Text> error message

* Regenerate `codes.json`
2020-08-17 10:47:49 -07:00
aa89331b44 Fix: React cannot render in ShadowRoot (#15894)
* fix: render in shadow root

* fix: flow typing

* Remove types and turn invariant into warning

Co-authored-by: Dan Abramov <[email protected]>
2020-08-17 15:47:49 +01:00
Dan Abramov b9fc7f21d2 [email protected] 2020-08-17 13:31:20 +01:00
Dan AbramovandGitHub 3d2b5d4a76 Update CHANGELOG.md 2020-08-17 13:30:16 +01:00
2bf141b574 refactor fb.me redirect link to reactjs.org/link (#19598)
* refactor fb.me url to reactjs.org/link

* Update ESLintRuleExhaustiveDeps-test.js

* Update ReactDOMServerIntegrationUntrustedURL-test.internal.js

* Update createReactClassIntegration-test.js

* Update ReactDOMServerIntegrationUntrustedURL-test.internal.js

Co-authored-by: Dan Abramov <[email protected]>
2020-08-17 13:25:50 +01:00
Toru KobayashiandGitHub ef7ec502ba fix: leak strict mode with UMD builds (#19614) 2020-08-15 14:42:49 +01:00
Brian VaughnandGitHub 7012428b49 Improve error boundary handling for unmounted subtrees (#19542)
A passive effect's cleanup function may throw after an unmount. Prior to this commit, such an error would be ignored. (React would not notify any error boundaries.) After this commit, React's behavior varies depending on which reconciler fork is being used.

For the old reconciler, React will call componentDidCatch for the nearest unmounted error boundary (if there is one). If there are no unmounted error boundaries, React will still swallow the error because the return pointer has been disconnected, so the normal error handling logic does not know how to traverse the tree to find the nearest still-mounted ancestor.

For the new reconciler, React will skip any unmounted boundaries and look for a still-mounted boundary. If one is found, it will call getDerivedStateFromError and/or componentDidCatch (depending on the type of boundary).

Tests have been added for both reconciler variants for now.
2020-08-14 16:46:46 -04:00
Brian VaughnandGitHub 34e91f0b80 Permanently removed component stacks from scheduling profiler data (#19615)
These stacks improve the profiler data but they're expensive to generate and generating them can also cause runtime errors in larger applications (although an exact repro has been hard to nail down). Removing them for now. We can revisit adding them after this profiler has been integrated into the DevTools extension and we can generate them lazily.
2020-08-14 15:21:13 -04:00
Andrew Clark 601c759449 Remove didTimeout check from work loop
No longer need this, since we have starvation protection in userspace.

This will also allow us to remove the concept from the Scheduler
package, which is nice because `postTask` doesn't currently support it.
2020-08-14 10:45:24 -04:00
Andrew Clark 8e96016805 Remove wasteful checks from shouldYield
`shouldYield` will currently return `true` if there's a higher priority
task in the Scheduler queue.

Since we yield every 5ms anyway, this doesn't really have any practical
benefit. On the contrary, the extra checks on every `shouldYield` call
are wasteful.
2020-08-14 10:45:11 -04:00
Clay TercekandGitHub 27ca06d906 fix event.relatedTarget fallback logic for firefox (#19607)
* fix event.relatedTarget fallback logic for firefox

* check if relatedTarget is undefined for fallback
2020-08-14 13:05:53 +01:00
Jordan EldredgeandGitHub 4876988c46 [eslint-plugin-react-hooks] Report constant constructions (#19590)
* [eslint-plugin-react-cooks] Report constant constructions

The dependency array passed to a React hook can be thought of as a list of cache keys. On each render, if any dependency is not `===` its previous value, the hook will be rerun. Constructing a new object/array/function/etc directly within your render function means that the value will be referentially unique on each render. If you then use that value as a hook dependency, that hook will get a "cache miss" on every render, making the dependency array useless.

This can be especially dangerous since it can cascade. If a hook such as `useMemo` is rerun on each render, not only are we bypassing the option to avoid potentially expensive work, but the value _returned_ by `useMemo` may end up being referentially unique on each render causing other downstream hooks or memoized components to become deoptimized.

* Fix/remove existing tests

* Don't give an autofix of wrapping object declarations

It may not be safe to just wrap the declaration of an object, since the object may get mutated.

Only offer this autofix for functions which are unlikely to get mutated.

Also, update the message to clarify that the entire construction of the value should get wrapped.

* Handle the long tail of nodes that will be referentially unique

* Catch let/var constant constructions on initial assignment

* Trim trailing whitespace

* Address feedback from @gaearon

* Rename "assignment" to "initialization"

* Add test for a constant construction used in multiple dependency arrays
2020-08-13 20:54:33 +01:00
Sebastian MarkbågeandGitHub ada150793d Move commit passive unmount/mount to CommitWork (#19599) 2020-08-13 09:17:33 -07:00
Brian VaughnandGitHub 7b32e7cdfc Fix emoji character displayed in Chrome extension (#19603) 2020-08-13 11:16:35 -04:00
inottnandGitHub 2affd3caf9 Remove unused argument (#19600) 2020-08-13 15:11:01 +01:00
Andrew ClarkandGitHub 9e5b400236 [Scheduler] Re-throw unhandled errors (#19595)
Because `postTask` returns a promise, errors inside a `postTask`
callback result in the promise being rejected.

If we don't catch those errors, then the browser will report an
"Unhandled promise rejection" error. This is a confusing message to see
in the console, because the fact that `postTask` is a promise-based API
is an implementation detail from the perspective of the developer.
"Promise rejection" is a red herring.

On the other hand, if we do catch those errors, then we need to report
the error to the user in some other way.

What we really want is the default error reporting behavior that a
normal, non-Promise browser event gets.

So, we'll re-throw inside `setTimeout`.
2020-08-12 20:06:43 -07:00
Pascal Fong KyeandGitHub 8fa4975389 DevTools bug fix: Proxied methods should be safely dehydrated for display 2020-08-12 12:15:53 -04:00
Andrew ClarkandGitHub c3c5f85dd5 [Scheduler] Call postTask directly (#19551)
This updates the experimental Scheduler postTask build to call postTask
directly, instead of managing our own custom queue and work loop.

We still use a deadline 5ms mechanism to implement `shouldYield`.

The main thing that postTask is currently missing is the continuation
feature — when yielding to the main thread, the yielding task is sent
to the back of the queue, instead of maintaining its position.

While this would be nice to have, even without it, postTask may be good
enough to replace our userspace implementation.

We'll run some tests to see.
2020-08-12 08:39:47 -05:00
RickyandGitHub 250a263a1a Speed up yarn cache in circle (#19566) 2020-08-11 14:05:15 -04:00
Dan AbramovandGitHub dea87e1b8b Remove resolutions from test renderer package.json (#19577) 2020-08-10 20:45:12 +01:00
4c057d61fa Add ReactVersion to SchedulingProfiler render scheduled marks (#19553)
* Add ReactVersion to SchedulingProfiler render scheduled marks

* Move ReactVersion to a new --react-init-* mark

Co-authored-by: E-Liang Tan <[email protected]>
2020-08-10 10:51:25 -04:00
4b1315011f Support inner component _debugOwner in memo (#19556)
* Support inner component _debugOwner in memo

* test with devtool context

* remove memo test

* Merged master; tweaked test and snapshot

* Pass owner to createFiber fn when creating a memo component.

Co-authored-by: Theodore Han <[email protected]>
2020-08-10 10:49:10 -04:00
0699edff44 Fix double-firing mouseenter (#19571)
* test: Simulate mouseover in browser

* Fix duplicate onMouseEnter event when relatedTarget is a root

* Test leave as well

Co-authored-by: Sebastian Silbermann <[email protected]>
2020-08-10 15:08:22 +01:00
Dan Abramov 7366840cb6 Rename test files 2020-08-10 12:58:42 +01:00
c07648fdc2 fix: onFocus/onBlur/onBeforeInput have a matching event type (#19561)
* test: Add current behavior for event types of onFocus/onBlur

* fix: onFocus/onBlur have a matching event type

* fix useFocus

* fix: don't compare native event types with react event types

* Add FocusIn/FocusOutEventInterface

* A simpler alternative fix

* Add regression tests

* Always pass React event type and fix beforeinput

Co-authored-by: Dan Abramov <[email protected]>
2020-08-10 12:54:10 +01:00
Sebastian SilbermannandGitHub 5e2fa445fb Update outdated lockfile (#19568) 2020-08-10 11:59:37 +01:00
Andrew ClarkandGitHub 082ba4fa61 Parallelize Jest in CI (#19552)
Uses CircleCI's `parallelism` key to split our test jobs across multiple
processes, like we do for the build job.
2020-08-07 16:32:59 -04:00
Dan Abramov da936f89c5 Indent a command 2020-08-07 19:24:49 +01:00
Dan Abramov 5b16347122 Fix command 2020-08-07 19:23:43 +01:00
f764c76a38 Nesting Fixture (#19531)
* Nesting Fixture

* Add README to nesting fixture

* Apply suggestions from code review

Co-authored-by: Ricky <[email protected]>

* Fixes

* Add Redux

* Use different versions

* Use Consumer API

* Rename helper

* Write docs

* Update README.md

* Update README.md

Co-authored-by: Rick Hanlon <[email protected]>
2020-08-07 02:08:41 +01:00
Brian VaughnandGitHub d0e061078b Warn about undefined return value for memo and forwardRef (#19550) 2020-08-06 16:12:32 -04:00
RickyandGitHub b131907867 Add feature flag for setting update lane priority (#19401)
* Add feature flag for setting update lane priority

* Remove second feature flag

* Refactor feature flag locations

* Add missing else
2020-08-06 12:47:32 -04:00
Gustavo SaianiandGitHub 2e6004e8fe Remove unused argument from call to jest method (#19546) 2020-08-06 16:55:01 +01:00
Mateusz BurzyńskiandGitHub c817a0e7be Register more node types that are used later as JSXIdentifiers (#19514) 2020-08-06 16:37:32 +01:00
DaniAcuandGitHub 87e32ba133 fix(react-dom): unnecesary path on DOMEventProperties (#19544) 2020-08-06 16:37:06 +01:00
Dominic GannawayandGitHub ba17a5da44 Re-add discrete flushing timeStamp heuristic (behind flag) (#19540) 2020-08-06 13:21:05 +01:00
Brian VaughnandGitHub 4f0802dd6d Fix runtime error that happens if a passive destroy function throws within an unmounted tree (#19543)
A passive effect's cleanup function may throw after an unmount. In that event, React sometimes threw an uncaught runtime error trying to access a property on a null stateNode field. This commit fixes that (and adds a regression test).
2020-08-05 18:22:18 -04:00
Emilis BaliukonisandGitHub 689998392f [Scheduler] Get current time from performance.now in non-DOM environments (#19532)
* Get current time from performance.now in non-DOM environments

* Use local references to native APIs for Date and Performance

* Refactored to read globals directly
2020-08-05 17:29:06 +01:00
Dan AbramovandGitHub 54c651dfb2 Remove onScroll bubbling flag (#19535) 2020-08-05 16:07:58 +01:00
Dominic GannawayandGitHub cd2ab43b72 Remove the deprecated React Flare event system (#19520) 2020-08-05 15:13:29 +01:00
Halit OguncandGitHub 48cfe4b2d3 fix: typo in React Release Scripts (#19524) 2020-08-04 13:22:50 -04:00
RickyandGitHub e237cd732b Use RN fork in default branch of feature flags (#19522) 2020-08-03 17:40:58 -04:00