mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright 2014-present, 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 ReactComponentEnvironment
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var invariant = require('invariant');
|
|
|
|
var injected = false;
|
|
|
|
var ReactComponentEnvironment = {
|
|
|
|
/**
|
|
* Optionally injectable hook for swapping out mount images in the middle of
|
|
* the tree.
|
|
*/
|
|
replaceNodeWithMarkup: null,
|
|
|
|
/**
|
|
* Optionally injectable hook for processing a queue of child updates. Will
|
|
* later move into MultiChildComponents.
|
|
*/
|
|
processChildrenUpdates: null,
|
|
|
|
injection: {
|
|
injectEnvironment: function(environment) {
|
|
invariant(
|
|
!injected,
|
|
'ReactCompositeComponent: injectEnvironment() can only be called once.'
|
|
);
|
|
ReactComponentEnvironment.replaceNodeWithMarkup =
|
|
environment.replaceNodeWithMarkup;
|
|
ReactComponentEnvironment.processChildrenUpdates =
|
|
environment.processChildrenUpdates;
|
|
injected = true;
|
|
},
|
|
},
|
|
|
|
};
|
|
|
|
module.exports = ReactComponentEnvironment;
|