React Developer Tools give a lot of power to inspect the React component tree, and look at props, event handlers, etc. However, what I'd really like to do is to be able to inspect those data structures in the browser console.
In chrome I can play with the currently selected DOM element in the console using $0
. Is there a way to extract React component info from $0
, or is it possible to do something similar with the React Dev Tools?
Using React Developer Tools you can use $r
to get a reference to the selected React Component.
The following screenshot shows you that I use React Developer Tools
to select a component (Explorer
) which has a state-object callednodeList
. In the console I can now simply write $r.state.nodeList
to reference this object in the state. Same works with the props (eg.: $r.props.path
)