Reputation: 3087
I created an app with Create React App.
How can I add global debug functions (e.g. resetDatabase()
) that I can call from Chromes Debug Console (or some other way)?
Upvotes: 8
Views: 531
Reputation: 47
Refer this site -: IT gives you the complete guide for that or if you face any issue feel free to ask https://developers.google.com/web/tools/chrome-devtools/console/
Upvotes: 1
Reputation: 155
You can attach the function to the global window object, or some namespaced object.
Then in the console you can run it with:
window.resetDatabase();
Here’s a link to a relevant post about accessing the global context through the componentWillMount callback.
How to declare a global variable in React?
Upvotes: 2