@samitouri / QOS-React / commits / f784a2d50a

Type ReactComponentEnvironment (#7566)

Christopher Chedeau committed Aug 25, 2016 at 20:08 UTC f784a2d50a4ec404de8239047088c72a9062fefe
1 file changed +12 -3
src/renderers/shared/stack/reconciler/ReactComponentEnvironment.js
+12 -3
@@ -7,12 +7,21 @@
7 * of patent rights can be found in the PATENTS file in the same directory.
8 *
9 * @providesModule ReactComponentEnvironment
10 + * @flow
11 */
12
13 'use strict';
14
15 var invariant = require('invariant');
16
17 +type ReplaceNodeWithMarkup = (node: HTMLElement, markup: string) => void;
18 +type ProcessChildrenUpdates = (instance: mixed, updates: mixed) => void;
19 +
20 +type Environment = {
21 + replaceNodeWithMarkup: ReplaceNodeWithMarkup,
22 + processChildrenUpdates: ProcessChildrenUpdates,
23 +};
24 +
25 var injected = false;
26
27 var ReactComponentEnvironment = {
@@ -21,16 +30,16 @@ var ReactComponentEnvironment = {
30 * Optionally injectable hook for swapping out mount images in the middle of
31 * the tree.
32 */
24 - replaceNodeWithMarkup: null,
33 + replaceNodeWithMarkup: (null: ?ReplaceNodeWithMarkup),
34
35 /**
36 * Optionally injectable hook for processing a queue of child updates. Will
37 * later move into MultiChildComponents.
38 */
30 - processChildrenUpdates: null,
39 + processChildrenUpdates: (null: ?ReplaceNodeWithMarkup),
40
41 injection: {
33 - injectEnvironment: function(environment) {
42 + injectEnvironment: function(environment: Environment) {
43 invariant(
44 !injected,
45 'ReactCompositeComponent: injectEnvironment() can only be called once.'