mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
react app
This commit is contained in:
74
react-app/node_modules/react/lib/ReactContext.js
generated
vendored
Normal file
74
react-app/node_modules/react/lib/ReactContext.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ReactContext
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var assign = require("./Object.assign");
|
||||
var emptyObject = require("./emptyObject");
|
||||
var warning = require("./warning");
|
||||
|
||||
var didWarn = false;
|
||||
|
||||
/**
|
||||
* Keeps track of the current context.
|
||||
*
|
||||
* The context is automatically passed down the component ownership hierarchy
|
||||
* and is accessible via `this.context` on ReactCompositeComponents.
|
||||
*/
|
||||
var ReactContext = {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @type {object}
|
||||
*/
|
||||
current: emptyObject,
|
||||
|
||||
/**
|
||||
* Temporarily extends the current context while executing scopedCallback.
|
||||
*
|
||||
* A typical use case might look like
|
||||
*
|
||||
* render: function() {
|
||||
* var children = ReactContext.withContext({foo: 'foo'}, () => (
|
||||
*
|
||||
* ));
|
||||
* return <div>{children}</div>;
|
||||
* }
|
||||
*
|
||||
* @param {object} newContext New context to merge into the existing context
|
||||
* @param {function} scopedCallback Callback to run with the new context
|
||||
* @return {ReactComponent|array<ReactComponent>}
|
||||
*/
|
||||
withContext: function(newContext, scopedCallback) {
|
||||
if ("production" !== process.env.NODE_ENV) {
|
||||
("production" !== process.env.NODE_ENV ? warning(
|
||||
didWarn,
|
||||
'withContext is deprecated and will be removed in a future version. ' +
|
||||
'Use a wrapper component with getChildContext instead.'
|
||||
) : null);
|
||||
|
||||
didWarn = true;
|
||||
}
|
||||
|
||||
var result;
|
||||
var previousContext = ReactContext.current;
|
||||
ReactContext.current = assign({}, previousContext, newContext);
|
||||
try {
|
||||
result = scopedCallback();
|
||||
} finally {
|
||||
ReactContext.current = previousContext;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = ReactContext;
|
Reference in New Issue
Block a user