Created
November 20, 2019 13:21
-
-
Save Connormiha/52b9b529ccbfa5114802d0e5304e04f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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