Skip to content

Commit c73a9c4

Browse files
sebmarkbagejetoneza
authored andcommitted
Add Debug Tools Package for Introspection of Hooks (facebook#14085)
* Add debug tools package * Add basic implementation * Implement inspection of the current state of hooks using the fiber tree * Support useContext hooks inspection by backtracking from the Fiber I'm not sure this is safe because the return fibers may not be current but close enough and it's fast. We use this to set up the current values of the providers. * rm copypasta * Use lastIndexOf Just in case. I don't know of any scenario where this can happen. * Support ForwardRef * Add test for memo and custom hooks * Support defaultProps resolution
1 parent 3d56f14 commit c73a9c4

File tree

14 files changed

+1265
-150
lines changed

14 files changed

+1265
-150
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"create-react-class": "^15.6.3",
4545
"cross-env": "^5.1.1",
4646
"danger": "^3.0.4",
47+
"error-stack-parser": "^2.0.2",
4748
"eslint": "^4.1.0",
4849
"eslint-config-fbjs": "^1.1.1",
4950
"eslint-plugin-babel": "^3.3.0",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# react-debug-tools
2+
3+
This is an experimental package for debugging React renderers.
4+
5+
**Its API is not as stable as that of React, React Native, or React DOM, and does not follow the common versioning scheme.**
6+
7+
**Use it at your own risk.**
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
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+
'use strict';
9+
10+
const ReactDebugTools = require('./src/ReactDebugTools');
11+
12+
// This is hacky but makes it work with both Rollup and Jest.
13+
module.exports = ReactDebugTools.default || ReactDebugTools;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/react-debug-tools.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/react-debug-tools.development.js');
7+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "react-debug-tools",
3+
"description": "React package for debugging React trees.",
4+
"version": "0.16.0",
5+
"keywords": [
6+
"react"
7+
],
8+
"homepage": "https://reactjs.org/",
9+
"bugs": "https://github.com/facebook/react/issues",
10+
"license": "MIT",
11+
"files": [
12+
"LICENSE",
13+
"README.md",
14+
"index.js",
15+
"cjs/"
16+
],
17+
"main": "index.js",
18+
"repository": "facebook/react",
19+
"engines": {
20+
"node": ">=0.10.0"
21+
},
22+
"peerDependencies": {
23+
"react": "^16.0.0"
24+
},
25+
"dependencies": {
26+
"error-stack-parser": "^2.0.2"
27+
}
28+
}

0 commit comments

Comments
 (0)