Commit Graph
60 Commits
Author SHA1 Message Date
Dominic GannawayandGitHub 8e16f11d59 [Flare] Refinements to useEvent hook (#15955) 2019-06-21 23:10:55 +01:00
Dominic GannawayandGitHub 3ae909dcd4 [Flare] Refine flow type annotations (#15950) 2019-06-21 12:32:43 +01:00
Dominic GannawayandAndrew Clark 498afc97c5 [Flare] Add useEvent hook implementation (#15927)
* [Flare] Add useEvent hook implementation

Validate hooks have decendent event components

Few fixes and displayName changes

Fix more responder bugs

Update error codes

* Add another test

* Address feedback
2019-06-20 19:12:40 -07:00
Dominic GannawayandGitHub 751d4b4363 [Flare] Add RN build step for ReactTypes (#15926) 2019-06-19 13:27:10 +01:00
Dominic GannawayandGitHub f01586ec26 [Flare] Move unstable_createEventComponent to ReactDOM (#15890) 2019-06-18 23:41:00 +01:00
Dominic GannawayandGitHub 5a9b7905bd [Flare] remove stopLocalPropagation option + modify responder ownership (#15889) 2019-06-14 23:11:54 +01:00
Dominic GannawayandGitHub 5ba77153c7 [Flare] Refactor of Press to fix various issues (#15878) 2019-06-14 22:52:26 +01:00
Dominic GannawayandGitHub 65a204c79c [Flare] Improve runtime performance of hit target intersection (#15836) 2019-06-07 15:57:10 +01:00
Dominic GannawayandGitHub 43e15a453a [Flare] Fix ES6 issues with IE11 (#15834) 2019-06-06 18:38:46 +01:00
Andrew ClarkandGitHub a50a107140 [Flare] EventPriority enum (#15823)
* Same as previous commit, but for Flare

I don't know what the public API for setting the event priority should
be. Right now it accepts a numeric enum, but is this what we want?
Maybe it should be a string enum? I've punted on this for now.

* Add test for hover events
2019-06-04 17:20:06 -07:00
Dominic GannawayandGitHub 25789d6ccd [Flare] Deeply prevent default on anchor elements (#15750) 2019-05-28 12:46:07 +01:00
Dominic GannawayandGitHub 6e1f3963be [Flare] event component displayName is now mandatory (#15717) 2019-05-23 01:29:07 +01:00
Dominic GannawayandGitHub 7265fe8827 Flare: simplify dispatchEvent discrete argument (#15694) 2019-05-21 16:06:17 +01:00
Dominic GannawayandGitHub ce7ca99646 Event API: Add responder allowMultipleHostChildren flag (#15646) 2019-05-16 19:03:38 +01:00
Dominic GannawayandGitHub fc9f6e3e61 Event API: ensure preventDefault works for nested targets (#15633) 2019-05-13 13:45:48 +01:00
Dominic GannawayandGitHub 49ed3e10df Event API: normalize event timeStamp property to be in event system (#15598) 2019-05-09 16:05:25 +01:00
Dominic GannawayandGitHub 5ec2d02ed8 Experimental Event API: reduce code size of event modules (#15590) 2019-05-08 19:09:32 +01:00
Dominic GannawayandGitHub fcda38dc4b Event API: remove isTargetDirectlyWithinEventComponent (#15546) 2019-04-30 17:38:48 +01:00
Dominic GannawayandGitHub 1182935a19 Event API: use capture for all event listeners using experimental responder system (#15526) 2019-04-30 11:40:45 +01:00
Dominic GannawayandGitHub 33eca02efe Event API: follow up fixes for FocusScope + context changes (#15496) 2019-04-25 20:10:33 +01:00
shubhamandChristoph Nakazawa 4691a199a1 typo fix (#15493)
changed ReactResponderContext.dispatchEvent otpions keys to options.
2019-04-25 09:37:35 +01:00
Dominic GannawayandGitHub 9fe417c482 Event API: Add FocusScope surface (#15487) 2019-04-25 02:01:09 +01:00
Dominic GannawayandGitHub 3835e2a033 Experimental event API: adds context.isTargetDirectlyWithinEventComponent (#15481) 2019-04-24 11:02:47 +01:00
Dominic GannawayandGitHub b18b53eb40 Experimental Event API: add event component mount phase callback (#15480) 2019-04-24 10:41:24 +01:00
Dominic GannawayandGitHub 3d3991dd3f Experimental Event API: add rootEventTypes support to event responders (#15475)
* Adds rootEventTypes
2019-04-23 19:55:50 +01:00
Dominic GannawayandGitHub eedf16b8cd Experimental event API: rework the propagation system for event components (#15462) 2019-04-23 11:50:48 +01:00
Dominic GannawayandGitHub 9479cae28e Experimental Event API: Redesign event responder propagation (#15408)
* Event API: Redesign event instance propagation
2019-04-13 20:37:39 +01:00
Dominic GannawayandGitHub 031d2a60e7 Experimental Event API: Remove "listener" from event objects (#15391) 2019-04-12 11:53:40 +01:00
Dominic GannawayandGitHub f2e4c74d43 Experimental Event API: adds stopPropagation by default to Press (#15384) 2019-04-11 20:00:20 +01:00
Dominic GannawayandGitHub 31152f65b5 Experimental Event API: Add targets and responder utility method for finding targets (#15372) 2019-04-10 18:52:34 +01:00
Dominic GannawayandGitHub b7a59ac234 Move EventTypes to ReactTypes (#15364) 2019-04-10 09:55:56 +01:00
Dominic GannawayandGitHub 8a9f31eb53 Refactor EventComponent logic + add onOwnershipChange callback (#15354) 2019-04-09 12:47:32 +01:00
Dominic GannawayandGitHub 3b24a08957 Experimental event API: refactor responder modules for lifecycle inclusion (#15322) 2019-04-04 23:28:23 +01:00
Dominic GannawayandGitHub 9c7b58deb2 Adds displayName to EventComponent and EventTarget (#15268)
* Adds displayName to EventComponent and EventTarget
2019-04-03 12:24:25 +01:00
Dominic GannawayandGitHub 2cbd73acd6 Adds more scaffolding for experimental event API (#15112)
* Adds more scaffolding for experimental event API
2019-03-20 11:20:17 +00:00
Dominic GannawayandGitHub 1b83e80746 Adds react-events package for internal testing (#15150)
* Adds react-events package for internal testing
2019-03-19 15:12:45 +00:00
Dominic GannawayandGitHub c6db700762 Adds experimental event API scaffolding (#15108)
* Adds experimental event API scaffolding
2019-03-14 17:02:42 +00:00
Sebastian MarkbågeandGitHub 5d9dcbe13f Use unique thread ID for each partial render to access Context (#14182)
* BUG: ReactPartialRenderer / New Context polutes mutable global state

The new context API stores the provided values on the shared context instance. When used in a synchronous context, this is not an issue. However when used in an concurrent context this can cause a "push provider" from one react render to have an effect on an unrelated concurrent react render.

I've encountered this bug in production when using renderToNodeStream, which asks ReactPartialRenderer for bytes up to a high water mark before yielding. If two Node Streams are created and read from in parallel, the state of one can polute the other.

I wrote a failing test to illustrate the conditions under which this happens.

I'm also concerned that the experimental concurrent/async React rendering on the client could suffer from the same issue.

* Use unique thread ID for each partial render to access Context

This first adds an allocator that keeps track of a unique ThreadID index
for each currently executing partial renderer. IDs are not just growing
but are reused as streams are destroyed.

This ensures that IDs are kept nice and compact.

This lets us use an "array" for each Context object to store the current
values. The look up for these are fast because they're just looking up
an offset in a tightly packed "array".

I don't use an actual Array object to store the values. Instead, I rely
on that VMs (notably V8) treat storage of numeric index property access
as a separate "elements" allocation.

This lets us avoid an extra indirection.

However, we must ensure that these arrays are not holey to preserve this
feature.

To do that I store the _threadCount on each context (effectively it takes
the place of the .length property on an array).

This lets us first validate that the context has enough slots before we
access the slot. If not, we fill in the slots with the default value.
2018-11-09 15:38:20 -08:00
Dan AbramovandGitHub 40701d0d9b Remove unstable_read() in favor of direct dispatcher call (#13861)
* Remove unstable_read() in favor of direct dispatcher call

* This no longer throws immediately
2018-10-16 14:58:00 -04:00
Brian NgandDan Abramov 3944c5f577 Bump babel-eslint and remove flow supressions (#13727) 2018-09-25 22:48:31 +01:00
Dan AbramovandGitHub 96af335cd7 Enable no-use-before-define rule (#13606) 2018-09-10 16:15:18 +01:00
Héctor RamosandGitHub 7353a5add1 Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
EstebanandDan Abramov d5680ea657 Remove unused ReactCall & ReactReturn types (#13419)
These are no longer used after the removal of the `react-call-return` package.
2018-08-16 18:48:13 +01:00
Andrew ClarkandGitHub d59ed5145c Don't stop context traversal at matching consumers (#13391)
* Don't stop context traversal at matching consumers

Originally, the idea was to time slice the traversal. This worked when
there was only a single context type per consumer.

Now that each fiber may have a list of context dependencies, including
duplicate entries, that optimization no longer makes sense – we could
end up scanning the same subtree multiple times.

* Remove changedBits from context object and stack

Don't need it anymore, yay
2018-08-15 11:19:53 -07:00
Andrew ClarkandGitHub 14fa37a467 Remove unnecessary branching from updateContextProvider (#13282)
This code had gotten unnecessarily complex after some recent changes.
Cleaned it up a bit.
2018-07-27 13:42:17 -07:00
Andrew ClarkandGitHub bcb5dbab4a [Experimental] API for reading context from within any render phase function (#13139)
* Store list of contexts on the fiber

Currently, context can only be read by a special type of component,
ContextConsumer. We want to add support to all fibers, including
classes and functional components.

Each fiber may read from one or more contexts. To enable quick, mono-
morphic access of this list, we'll store them on a fiber property.

* Context.unstable_read

unstable_read can be called anywhere within the render phase. That
includes the render method, getDerivedStateFromProps, constructors,
functional components, and context consumer render props.

If it's called outside the render phase, an error is thrown.

* Remove vestigial context cursor

Wasn't being used.

* Split fiber.expirationTime into two separate fields

Currently, the `expirationTime` field represents the pending work of
both the fiber itself — including new props, state, and context — and of
any updates in that fiber's subtree.

This commit adds a second field called `childExpirationTime`. Now
`expirationTime` only represents the pending work of the fiber itself.
The subtree's pending work is represented by `childExpirationTime`.

The biggest advantage is it requires fewer checks to bailout on already
finished work. For most types of work, if the `expirationTime` does not
match the render expiration time, we can bailout immediately without
any further checks. This won't work for fibers that have
`shouldComponentUpdate` semantics (class components), for which we still
need to check for props and state changes explicitly.

* Performance nits

Optimize `readContext` for most common case
2018-07-20 16:49:06 -07:00
Timothy YungandGitHub 18a90b7d88 Fix Type for ReactNative.NativeComponent (#12805) 2018-05-14 16:36:50 -07:00
Andrew ClarkandGitHub 727d47650b Support sharing context objects between concurrent renderers (#12779)
* Support concurrent primary and secondary renderers.

As a workaround to support multiple concurrent renderers, we categorize
some renderers as primary and others as secondary. We only expect
there to be two concurrent renderers at most: React Native (primary) and
Fabric (secondary); React DOM (primary) and React ART (secondary).
Secondary renderers store their context values on separate fields.

* Add back concurrent renderer warning

Only warn for two concurrent primary or two concurrent secondary renderers.

* Change "_secondary" suffix to "2"

#EveryBitCounts
2018-05-10 18:34:01 -07:00
Mateusz BurzyńskiandDan Abramov dc1f4473bd Prefix _context property on returned ReactContext from createContext - it's private (#12501) 2018-04-03 01:47:25 +01:00
Rene Hangstrup MøllerandDan Abramov 74b79599f1 Rename bits to unstable_observedBits (#12440) 2018-03-23 15:58:49 +00:00