1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
13 |
|
14 | var ReactUpdateQueue = require('./ReactUpdateQueue');
|
15 |
|
16 | var warning = require('fbjs/lib/warning');
|
17 |
|
18 | function warnNoop(publicInstance, callerName) {
|
19 | if (process.env.NODE_ENV !== 'production') {
|
20 | var constructor = publicInstance.constructor;
|
21 | process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
|
22 | }
|
23 | }
|
24 |
|
25 | /**
|
26 | * This is the update queue used for server rendering.
|
27 | * It delegates to ReactUpdateQueue while server rendering is in progress and
|
28 | * switches to ReactNoopUpdateQueue after the transaction has completed.
|
29 | * @class ReactServerUpdateQueue
|
30 | * @param {Transaction} transaction
|
31 | */
|
32 |
|
33 | var ReactServerUpdateQueue = function () {
|
34 | function ReactServerUpdateQueue(transaction) {
|
35 | _classCallCheck(this, ReactServerUpdateQueue);
|
36 |
|
37 | this.transaction = transaction;
|
38 | }
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | ReactServerUpdateQueue.prototype.isMounted = function isMounted(publicInstance) {
|
50 | return false;
|
51 | };
|
52 |
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | ReactServerUpdateQueue.prototype.enqueueCallback = function enqueueCallback(publicInstance, callback, callerName) {
|
64 | if (this.transaction.isInTransaction()) {
|
65 | ReactUpdateQueue.enqueueCallback(publicInstance, callback, callerName);
|
66 | }
|
67 | };
|
68 |
|
69 | |
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | ReactServerUpdateQueue.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance) {
|
85 | if (this.transaction.isInTransaction()) {
|
86 | ReactUpdateQueue.enqueueForceUpdate(publicInstance);
|
87 | } else {
|
88 | warnNoop(publicInstance, 'forceUpdate');
|
89 | }
|
90 | };
|
91 |
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | ReactServerUpdateQueue.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState) {
|
106 | if (this.transaction.isInTransaction()) {
|
107 | ReactUpdateQueue.enqueueReplaceState(publicInstance, completeState);
|
108 | } else {
|
109 | warnNoop(publicInstance, 'replaceState');
|
110 | }
|
111 | };
|
112 |
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 | ReactServerUpdateQueue.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState) {
|
126 | if (this.transaction.isInTransaction()) {
|
127 | ReactUpdateQueue.enqueueSetState(publicInstance, partialState);
|
128 | } else {
|
129 | warnNoop(publicInstance, 'setState');
|
130 | }
|
131 | };
|
132 |
|
133 | return ReactServerUpdateQueue;
|
134 | }();
|
135 |
|
136 | module.exports = ReactServerUpdateQueue; |
\ | No newline at end of file |