mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Type ReactComponentEnvironment (#7566)
This commit is contained in:
committed by
GitHub
parent
66e77f696a
commit
f784a2d50a
@@ -7,12 +7,21 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ReactComponentEnvironment
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('invariant');
|
||||
|
||||
type ReplaceNodeWithMarkup = (node: HTMLElement, markup: string) => void;
|
||||
type ProcessChildrenUpdates = (instance: mixed, updates: mixed) => void;
|
||||
|
||||
type Environment = {
|
||||
replaceNodeWithMarkup: ReplaceNodeWithMarkup,
|
||||
processChildrenUpdates: ProcessChildrenUpdates,
|
||||
};
|
||||
|
||||
var injected = false;
|
||||
|
||||
var ReactComponentEnvironment = {
|
||||
@@ -21,16 +30,16 @@ var ReactComponentEnvironment = {
|
||||
* Optionally injectable hook for swapping out mount images in the middle of
|
||||
* the tree.
|
||||
*/
|
||||
replaceNodeWithMarkup: null,
|
||||
replaceNodeWithMarkup: (null: ?ReplaceNodeWithMarkup),
|
||||
|
||||
/**
|
||||
* Optionally injectable hook for processing a queue of child updates. Will
|
||||
* later move into MultiChildComponents.
|
||||
*/
|
||||
processChildrenUpdates: null,
|
||||
processChildrenUpdates: (null: ?ReplaceNodeWithMarkup),
|
||||
|
||||
injection: {
|
||||
injectEnvironment: function(environment) {
|
||||
injectEnvironment: function(environment: Environment) {
|
||||
invariant(
|
||||
!injected,
|
||||
'ReactCompositeComponent: injectEnvironment() can only be called once.'
|
||||
|
||||
Reference in New Issue
Block a user