forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactDebugCurrentFiber.js
More file actions
54 lines (47 loc) · 1.38 KB
/
ReactDebugCurrentFiber.js
File metadata and controls
54 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Copyright 2013-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 ReactDebugCurrentFiber
* @flow
*/
'use strict';
import type { Fiber } from 'ReactFiber';
if (__DEV__) {
var getComponentName = require('getComponentName');
var { getStackAddendumByWorkInProgressFiber } = require('ReactComponentTreeHook');
}
function getCurrentFiberOwnerName() : string | null {
if (__DEV__) {
const fiber = ReactDebugCurrentFiber.current;
if (fiber == null) {
return null;
}
if (fiber._debugOwner != null) {
return getComponentName(fiber._debugOwner);
}
}
return null;
}
function getCurrentFiberStackAddendum() : string | null {
if (__DEV__) {
const fiber = ReactDebugCurrentFiber.current;
if (fiber == null) {
return null;
}
// Safe because if current fiber exists, we are reconciling,
// and it is guaranteed to be the work-in-progress version.
return getStackAddendumByWorkInProgressFiber(fiber);
}
return null;
}
var ReactDebugCurrentFiber = {
current: (null : Fiber | null),
getCurrentFiberOwnerName,
getCurrentFiberStackAddendum,
};
module.exports = ReactDebugCurrentFiber;