Commit Graph

2228 Commits

Author SHA1 Message Date
Sunil Pai
b789060dca Feature Flag for React.jsx` "spreading a key to jsx" warning (#18074)
Adds a feature flag for when React.jsx warns you about spreading a key into jsx. It's false for all builds, except as a dynamic flag for fb/www.

I also included the component name in the warning.
2020-02-20 11:30:04 +00:00
Dominic Gannaway
3f85d53ca6 Further pre-requisite changes to plugin event system (#18083) 2020-02-20 00:46:03 +00:00
Andrew Clark
ea6ed3dbbd Warn for update on different component in render (#17099)
This warning already exists for class components, but not for functions.

It does not apply to render phase updates to the same component, which
have special semantics that we do support.
2020-02-19 12:43:14 -08:00
Eli White
085d02133e [Native] Migrate focus/blur to call TextInputState with the host component (#18068) 2020-02-19 11:33:40 -08:00
Brian Vaughn
7e770dae93 Profiler tooltip tweaks (#18082)
* Moved Profiler views into Profiler folder

* Tweaked Profiler tooltip CSS styles

* Tweaked Tooltip positioning code
2020-02-19 10:58:45 -08:00
Dominic Gannaway
b6c94d636c Add guard around FocusWithin responder root events (#18080) 2020-02-19 18:32:18 +00:00
Dominic Gannaway
1000f6135e Add container to event listener signature (#18075) 2020-02-19 18:00:57 +00:00
Moji Izadmehr
44e5f5e645 Add fiber summary tooltip to devtools profiling (#18048)
* Add tooltip component

* Separate logic of ProfilerWhatChanged to a component

* Add hovered Fiber info tooltip component

* Add flame graph chart tooltip

* Add commit ranked list tooltip

* Fix flow issues

* Minor improvement in filter

* Fix flickering issue

* Resolved issues on useCallbacks and mouse event listeners

* Fix lints

* Remove unnecessary useCallback
2020-02-19 09:44:31 -08:00
Dominic Gannaway
4912ba31e3 Add modern event system flag + rename legacy plugin module (#18073) 2020-02-19 14:36:39 +00:00
Andrew Clark
4d9f850065 Re-throw errors thrown by the renderer at the root in the complete phase (#18029)
* Re-throw errors thrown by the renderer at the root

React treats errors thrown at the root as a fatal because there's no
parent component that can capture it. (This is distinct from an
"uncaught error" that isn't wrapped in an error boundary, because in
that case we can fall back to deleting the whole tree -- not great, but
at least the error is contained to a single root, and React is left in a
consistent state.)

It turns out we didn't have a test case for this path. The only way it
can happen is if the renderer's host config throws. We had similar test
cases for host components, but none for the host root.

This adds a new test case and fixes a bug where React would keep
retrying the root because the `workInProgress` pointer was not advanced
to the next fiber. (Which in this case is `null`, since it's the root.)

We could consider in the future trying to gracefully exit from certain
types of root errors without leaving React in an inconsistent state. For
example, we should be able to gracefully exit from errors thrown in the
begin phase. For now, I'm treating it like an internal invariant and
immediately exiting.

* Add comment
2020-02-18 15:55:38 -08:00
Brian Vaughn
14afeb1033 Added missing feature flag 2020-02-18 14:49:57 -08:00
Brian Vaughn
691096c95d Split recent passive effects changes into 2 flags (#18030)
* Split recent passive effects changes into 2 flags

Separate flags can now be used to opt passive effects into:
1) Deferring destroy functions on unmount to subsequent passive effects flush
2) Running all destroy functions (for all fibers) before create functions

This allows us to test the less risky feature (2) separately from the more risky one.

* deferPassiveEffectCleanupDuringUnmount is ignored unless runAllPassiveEffectDestroysBeforeCreates is true
2020-02-18 14:19:43 -08:00
Andrew Clark
56d8a73aff [www] Disable Scheduler timeout w/ dynamic flag (#18069)
Before attempting to land an expiration times refactor, I want to see
if this particular change will impact performance (either positively
or negatively). I will test this with a GK.
2020-02-18 13:43:16 -08:00
Dominic Gannaway
1a6d8179b6 [react-interactions] Ensure onBeforeBlur fires for hideInstance (#18064) 2020-02-18 18:50:38 +00:00
Haseeb Furkhan Mohammed
d5ddc16a33 React developer tools extension for Microsoft Edge (#18041)
* Port Chrome extension to Microsoft Edge
2020-02-18 09:40:30 -08:00
Dominic Gannaway
f48a5e64e8 Further cleanup of plugin event system (#18056) 2020-02-18 13:31:59 +00:00
Dan Abramov
d533229fba Fix Prettier 2020-02-17 20:36:16 +00:00
Dan Abramov
56a8c35321 eslint-plugin-react-hooks@2.4.0 2020-02-17 20:26:56 +00:00
Will Douglas
93a229bab5 Update eslint rule exhaustive deps to use new suggestions feature (#17385)
This closes #16313
2020-02-17 20:24:27 +00:00
Dominic Gannaway
9def56ec0e Refactor DOM plugin system to single module (#18025) 2020-02-14 08:10:42 +00:00
Eli White
2d6be757df [Native] Delete NativeComponent and NativeMethodsMixin (#18036)
* [Native] Delete NativeComponent and NativeMethodsMixin

* Remove more files
2020-02-13 15:09:25 -08:00
Luna Ruan
d4f2b0379c Add Auto Import to Babel Plugin (#16626)
This babel transform is a fork of the @babel/plugin-transform-react-jsx transform and is for experimentation purposes only. We don't plan to own this code in the future, and we will upstream this to Babel at some point once we've proven out the concept.

As per the RFC to simplify element creation, we want to add the ability to auto import "react' directly from the babel plugin. This commit updates the babel plugin with two options:

1.) importSource: The React module to import from. Defaults to react.
2.) autoImport: The type of import. Defaults to none.
- none: Does not import React. JSX compiles to React.jsx etc.
- namespace: import * as _react from "react";. JSX compiles to _react.jsx etc.
- default: import _default from "react"; JSX compiles to _default.jsx etc.
- namedExports: import {jsx as _jsx} from "react"; JSX compiles to _jsx etc.
- require: var _react = _interopRequireWildcard(require("react"));. jSX compiles to _react.jsx etc.

namespace, default, and namedExports can only be used when sourceType: module and require can only be used when sourceType: script.

It also adds two pragmas (jsxAutoImport and jsxImportSource) that allow users to specify autoImport and importSource in the docblock.
2020-02-13 12:36:19 -08:00
Dan Abramov
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 Abramov
a607ea4c42 Remove getIsHydrating (#18019) 2020-02-12 01:01:29 +00:00
Dominic Gannaway
988f4b14ee Do not export passiveBrowserEventsSupported from Focus responder (#18022)
Remove code
2020-02-11 15:57:37 -08:00
Brian Vaughn
f7278034de Flush all passive destroy fns before calling create fns (#17947)
* Flush all passive destroy fns before calling create fns

Previously we only flushed destroy functions for a single fiber.

The reason this is important is that interleaving destroy/create effects between sibling components might cause components to interfere with each other (e.g. a destroy function in one component may unintentionally override a ref value set by a create function in another component).

This PR builds on top of the recently added deferPassiveEffectCleanupDuringUnmount kill switch to separate passive effects flushing into two separate phases (similar to layout effects).

* Change passive effect flushing to use arrays instead of lists

This change offers a small advantage over the way we did things previous: it continues invoking destroy functions even after a previous one errored.
2020-02-11 09:52:54 -08:00
Dominic Gannaway
df5faddcc2 Refactor commitPlacement to recursively insert nodes (#17996) 2020-02-10 23:38:24 +00:00
Dan Abramov
ab7b83a924 Stop exposing some internals on FB build (#18011) 2020-02-10 19:52:27 +00:00
Dan Abramov
517de74b0c Tweak comment wording (#18007)
* Revert "Update ReactFiberExpirationTime.js (#17825)"

This reverts commit b63cb6f6cf.

* Reword
2020-02-10 16:15:10 +00:00
haseeb
b63cb6f6cf Update ReactFiberExpirationTime.js (#17825)
replaced 'add' with 'subtract'
2020-02-10 12:37:49 +00:00
Jesse Katsumata
89c6042df3 fix: typo in test (#18005) 2020-02-10 12:34:09 +00:00
Sophie Alpert
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
Brian Vaughn
e05dedc415 Added $FlowFixMe to DevTools shell for module we Flow-ignore (#18001) 2020-02-07 14:36:51 -08:00
Dominic Gannaway
c55c34e46a Move React Map child check to behind flags or __DEV__ (#17995) 2020-02-07 12:21:50 +00:00
cutjavascript
901d76bc5c dataForRoots.set duplicate removal (#17993)
dataForRoots.set duplicate removal
2020-02-06 11:48:02 -08:00
Dan Abramov
3f814e7582 Fix Flow type for React Native (#17992) 2020-02-06 18:31:13 +00:00
Dominic Gannaway
256d78d11f Add feature flag for removing children Map support (#17990) 2020-02-06 13:19:35 +00:00
Andrew Clark
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
Murat ÇATAL
cddde45806 apply changes on editablevalue on blur feature implemented (#17062)
* apply changes on editablevalue on blur feature implemented

* Removed "Undo" button and unnecessary event.preventDefault()

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-02-04 11:05:01 -08:00
Dan Abramov
d6e08fe0a8 Remove Suspense priority warning (#17971)
* Remove Suspense priority warning

* Fix tests
2020-02-04 18:05:15 +00:00
Alfredo Granja
812277dab6 Fix onMouseEnter is fired on disabled buttons (#17675) 2020-02-04 14:56:55 +00:00
Sunil Pai
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åge
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
Brian Vaughn
7df32c4c8c Flush useEffect clean up functions in the passive effects phase (#17925)
* Flush useEffect clean up functions in the passive effects phase

This is a change in behavior that may cause broken product code, so it has been added behind a killswitch (deferPassiveEffectCleanupDuringUnmount)

* Avoid scheduling unnecessary callbacks for cleanup effects

Updated enqueuePendingPassiveEffectDestroyFn() to check rootDoesHavePassiveEffects before scheduling a new callback. This way we'll only schedule (at most) one.

* Updated newly added test for added clarity.

* Cleaned up hooks effect tags

We previously used separate Mount* and Unmount* tags to track hooks work for each phase (snapshot, mutation, layout, and passive). This was somewhat complicated to trace through and there were man tag types we never even used (e.g. UnmountLayout, MountMutation, UnmountSnapshot). In addition to this, it left passive and layout hooks looking the same after renders without changed dependencies, which meant we were unable to reliably defer passive effect destroy functions until after the commit phase.

This commit reduces the effect tag types to only include Layout and Passive and differentiates between work and no-work with an HasEffect flag.

* Disabled deferred passive effects flushing in OSS builds for now

* Split up unmount and mount effects list traversal
2020-02-03 12:30:01 -08:00
Evyatar
9944bf27fb Add version property to ReactDOM (#15780) 2020-02-03 11:19:04 -08:00
Dominic Gannaway
434770c3b4 Add beforeRemoveInstance method to ReactNoop (#17959) 2020-02-03 11:31:51 +00:00
Mark Huang
08c1f79e1e Fix Cannot read property 'sub' of undefined when navigating to plain-text pages (#17848)
Update various parts of DevTools to account for the fact that the global "hook" might be undefined if DevTools didn't inject it (due to the page's `contentType`) it (due to the page's `contentType`)
2020-02-02 12:04:48 -08:00
Brian Vaughn
9ad35905fa Add DevTools tests for copying complex values (#17948) 2020-01-31 15:17:57 -08:00
Deniz Susman
00745b053f Typo fix (#17946) 2020-01-31 14:51:43 -08:00
Farhad Yasir
d9a5170594 fix: check bigint in serializeToString and change it to string (#17931) 2020-01-31 14:35:59 -08:00