[Q/A] How to access __reactInternalInstance, __reactEventHandlers? #174
-
What happened?Why I can not get the properties : __reactInternalInstance and __reactEventHandlers of element from the Content Script inside chrome extension created by plasmo, but I can get the properties which project created by Create React App? Is there a way to get them from the scope of the chrome extension created by plasmo ? This is my code: 1、in Create React App(https://codesandbox.io/s/suspicious-maria-lss4ef) 2、in plasmo(https://codesandbox.io/s/serene-smoke-vd82de) VersionLatest What OS are you seeing the problem on?Windows, MacOSX What browsers are you seeing the problem on?Chrome Relevant log outputNo response (OPTIONAL) Contact DetailsNo response Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
@aaamoon can you give me an extension that can access these properties with a react web page that I can use to test with, that'd be helpful! This seems to me that we're trying to get an extension to inspect the react context's scoped property outside of its own instance. I'm not sure that's even possible?... Like not even with the extension, can you query those fields from the chrome console? All-in-all, I doubt this is something related to Plasmo. |
Beta Was this translation helpful? Give feedback.
-
@louisgv I've tried to create a extension without Plasmo and I can't get __reactInternalInstance, __reactEventHandlers also. Related Links: https://stackoverflow.com/questions/53197472/chrome-extension-content-script-is-not-showing-all-available-properties-in-dom I don't understand very well, if you can understand too well, can you give me an example of how to get __reactInternalInstance, __reactEventHandlers in Plasmo, thank you very much. |
Beta Was this translation helpful? Give feedback.
-
@louisgv I can query those fields from the chrome console. |
Beta Was this translation helpful? Give feedback.
-
@louisgv @aaamoon I faced same problem in developing projects, and I think it's not a problem of plasmo itself, it's actually a limitation of chrome for extension's development. Actually, you can't access all the properties of a DOM (or be called HTMLElement for some reason). You can test it via |
Beta Was this translation helpful? Give feedback.
-
@aaamoon As far as I know, we can achieve this goal with three parts:
For content script:
For background script:
We can use |
Beta Was this translation helpful? Give feedback.
@aaamoon As far as I know, we can achieve this goal with three parts:
For content script:
For background script: