UNPKG

3.36 kBJavaScriptView Raw
1/**
2 * Copyright 2015-present, 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 */
10
11'use strict';
12
13var warning = require('fbjs/lib/warning');
14
15function warnNoop(publicInstance, callerName) {
16 if (process.env.NODE_ENV !== 'production') {
17 var constructor = publicInstance.constructor;
18 process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
19 }
20}
21
22/**
23 * This is the abstract API for an update queue.
24 */
25var ReactNoopUpdateQueue = {
26
27 /**
28 * Checks whether or not this composite component is mounted.
29 * @param {ReactClass} publicInstance The instance we want to test.
30 * @return {boolean} True if mounted, false otherwise.
31 * @protected
32 * @final
33 */
34 isMounted: function (publicInstance) {
35 return false;
36 },
37
38 /**
39 * Enqueue a callback that will be executed after all the pending updates
40 * have processed.
41 *
42 * @param {ReactClass} publicInstance The instance to use as `this` context.
43 * @param {?function} callback Called after state is updated.
44 * @internal
45 */
46 enqueueCallback: function (publicInstance, callback) {},
47
48 /**
49 * Forces an update. This should only be invoked when it is known with
50 * certainty that we are **not** in a DOM transaction.
51 *
52 * You may want to call this when you know that some deeper aspect of the
53 * component's state has changed but `setState` was not called.
54 *
55 * This will not invoke `shouldComponentUpdate`, but it will invoke
56 * `componentWillUpdate` and `componentDidUpdate`.
57 *
58 * @param {ReactClass} publicInstance The instance that should rerender.
59 * @internal
60 */
61 enqueueForceUpdate: function (publicInstance) {
62 warnNoop(publicInstance, 'forceUpdate');
63 },
64
65 /**
66 * Replaces all of the state. Always use this or `setState` to mutate state.
67 * You should treat `this.state` as immutable.
68 *
69 * There is no guarantee that `this.state` will be immediately updated, so
70 * accessing `this.state` after calling this method may return the old value.
71 *
72 * @param {ReactClass} publicInstance The instance that should rerender.
73 * @param {object} completeState Next state.
74 * @internal
75 */
76 enqueueReplaceState: function (publicInstance, completeState) {
77 warnNoop(publicInstance, 'replaceState');
78 },
79
80 /**
81 * Sets a subset of the state. This only exists because _pendingState is
82 * internal. This provides a merging strategy that is not available to deep
83 * properties which is confusing. TODO: Expose pendingState or don't use it
84 * during the merge.
85 *
86 * @param {ReactClass} publicInstance The instance that should rerender.
87 * @param {object} partialState Next partial state to be merged with state.
88 * @internal
89 */
90 enqueueSetState: function (publicInstance, partialState) {
91 warnNoop(publicInstance, 'setState');
92 }
93};
94
95module.exports = ReactNoopUpdateQueue;
\No newline at end of file