Obiwahn
Obiwahn

Reputation: 3087

How can I add debug functions that I can call from Chrome Debugger Console to a Create React App?

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

Answers (2)

Janmesh Nayak
Janmesh Nayak

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

mossherder
mossherder

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

Related Questions