Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80517 views
1
/**
2
* Copyright 2014-2015, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule ReactComponentEnvironment
10
*/
11
12
'use strict';
13
14
var invariant = require("./invariant");
15
16
var injected = false;
17
18
var ReactComponentEnvironment = {
19
20
/**
21
* Optionally injectable environment dependent cleanup hook. (server vs.
22
* browser etc). Example: A browser system caches DOM nodes based on component
23
* ID and must remove that cache entry when this instance is unmounted.
24
*/
25
unmountIDFromEnvironment: null,
26
27
/**
28
* Optionally injectable hook for swapping out mount images in the middle of
29
* the tree.
30
*/
31
replaceNodeWithMarkupByID: null,
32
33
/**
34
* Optionally injectable hook for processing a queue of child updates. Will
35
* later move into MultiChildComponents.
36
*/
37
processChildrenUpdates: null,
38
39
injection: {
40
injectEnvironment: function(environment) {
41
("production" !== process.env.NODE_ENV ? invariant(
42
!injected,
43
'ReactCompositeComponent: injectEnvironment() can only be called once.'
44
) : invariant(!injected));
45
ReactComponentEnvironment.unmountIDFromEnvironment =
46
environment.unmountIDFromEnvironment;
47
ReactComponentEnvironment.replaceNodeWithMarkupByID =
48
environment.replaceNodeWithMarkupByID;
49
ReactComponentEnvironment.processChildrenUpdates =
50
environment.processChildrenUpdates;
51
injected = true;
52
}
53
}
54
55
};
56
57
module.exports = ReactComponentEnvironment;
58
59