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)?
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With