UNPKG

740 BJavaScriptView Raw
1/**
2 * Copyright 2013-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 ReactNodeTypes = require('./ReactNodeTypes');
14
15function getHostComponentFromComposite(inst) {
16 var type;
17
18 while ((type = inst._renderedNodeType) === ReactNodeTypes.COMPOSITE) {
19 inst = inst._renderedComponent;
20 }
21
22 if (type === ReactNodeTypes.HOST) {
23 return inst._renderedComponent;
24 } else if (type === ReactNodeTypes.EMPTY) {
25 return null;
26 }
27}
28
29module.exports = getHostComponentFromComposite;
\No newline at end of file