README
react-inspector
Power of Browser DevTools inspectors right inside your React app. Check out the interactive playground or storybook.
Install
NPM:
npm install react-inspector
Recommended versions:
- version
3.0.2
: If you are using React 16.8.4 or later. - version
2.3.1
: If you are using an ealier version of React.
<Inspector />
A shorthand for the inspectors.
<Inspector/>
is equivalent to<ObjectInspector>
or<DOMInspector>
if inspecting a DOM Node.<Inspector table/>
is equivalent to<TableInspector>
.
<ObjectInspector />
Like console.log
. Consider this as a glorified version of <pre>JSON.stringify(data, null, 2)</pre>
.
How it works
Tree state is saved at root. If you click to expand some elements in the hierarchy, the state will be preserved after the element is unmounted.
API
The component accepts the following props:
: the Javascript object you would like to inspect data: PropTypes.any
: specify the optional name of the root node, default to name: PropTypes.stringundefined
: an integer specifying to which level the tree should be initially expanded. expandLevel: PropTypes.number
: an array containing all the paths that should be expanded when the component is initialized, or a string of just one path expandPaths: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
- The path string is similar to JSONPath.
- It is a dot separated string like
$.foo.bar
.$.foo.bar
expands the path$.foo.bar
where$
refers to the root node. Note that it only expands that single node (but not all its parents and the root node). Instead, you should useexpandPaths={['
- It is a dot separated string like