UNPKG

894 BJavaScriptView Raw
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 *
8 */
9
10'use strict';
11
12var _prodInvariant = require('./reactProdInvariant');
13
14var React = require('react/lib/React');
15
16var invariant = require('fbjs/lib/invariant');
17
18var ReactNodeTypes = {
19 HOST: 0,
20 COMPOSITE: 1,
21 EMPTY: 2,
22
23 getType: function (node) {
24 if (node === null || node === false) {
25 return ReactNodeTypes.EMPTY;
26 } else if (React.isValidElement(node)) {
27 if (typeof node.type === 'function') {
28 return ReactNodeTypes.COMPOSITE;
29 } else {
30 return ReactNodeTypes.HOST;
31 }
32 }
33 !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unexpected node: %s', node) : _prodInvariant('26', node) : void 0;
34 }
35};
36
37module.exports = ReactNodeTypes;
\No newline at end of file