Skip to content

Instantly share code, notes, and snippets.

@Connormiha
Created November 20, 2019 13:21
Show Gist options
  • Save Connormiha/52b9b529ccbfa5114802d0e5304e04f0 to your computer and use it in GitHub Desktop.
Save Connormiha/52b9b529ccbfa5114802d0e5304e04f0 to your computer and use it in GitHub Desktop.
(function(rootId) {
var appStates = []
var reactRoot = document.querySelector('#' + rootId);
var base
try {
base = reactRoot._reactRootContainer._internalRoot.current
} catch (e) {
console.log('Could not get internal root information from reactRoot element')
}
while (base) {
try {
// This also sometimes works...
// state = base.stateNode.store.getState()
appStates.push(base.pendingProps.store.getState())
} catch (e) {
// no state
}
base = base.child
}
console.log('Application States');
if (appStates.length) {
console.log(appStates[0]);
console.log(JSON.stringify(appStates[0]));
}
})('body');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment