Reputation: 6467
If I have to run the stopBefore
snippet as in the gist, how do I use it for ReactJS application?
The example shows for global object like document
, but if I have to say stop before ComponentX.SomeMethod
, how do I do it?
When trying
stopBefore(ComponentX,'SomeMethod')
It says, Uncaught ReferenceError: ComponentX is not defined
Am I missing something?
Upvotes: 1
Views: 320
Reputation: 898
React components are not globally available.
Hence can't be accessed directly in the console. But you can open Components tab in react-dev-tools than select the desired component and now open the console at the same time if not already using Esc key and type in $r in console to get the component's instance.
Now you can do whatever you desire-
stopBefore($r, 'setState')
As soon as you type
$r.setState({})
You will be taken to the debugger.
Upvotes: 1