Cannot read property 'setIcon' of undefined"
Closed this issue · 6 comments
When running Electron with devtools installed, the following error is being emitted in console
"Uncaught TypeError: Cannot read property 'setIcon' of undefined", source: chrome-extension://react-developer-tools/build/background.js (1)
After updating from react 16.4.1 to 16.8.1, I'm seeing something similar in Electron for components still using legacy context.
For functional components with context but no hooks, the devtools do not show the context section. For functional components with both context and hooks, the devtools do not show the context section, do show the hooks section with just "Loading...", and error trying to read from context:
electron-renderer-console-transport.js?4018:60 [Global window error]: TypeError: Cannot read property 'store' of undefined
at BulkHoldBanner (index.js?71fe:9)
at backend.js:1
at S (backend.js:1)
at i (backend.js:1)
at e.<anonymous> (backend.js:1)
at e.r.emit (backend.js:1)
at backend.js:1
at backend.js:1
at Array.forEach (<anonymous>)
at backend.js:1
at Array.forEach (<anonymous>)
at t.value (backend.js:1)
at e (backend.js:1)
If a functional component does not have contextTypes
defined, the devtools work as expected, even with hooks.
For class components, it's less clear to me what's happening; the devtools show some context properties, but they're not correct. For instance, one context property is a class instance. When accessed from the dev tools, it acts as though this instance has not had its constructor run. I believe this is due to something in the devtools because the components work as expected when reading from context. Additionally, the same instance which is injected into context is also available on window
and behaves normally from there.
This all seems similar to #1174, but I'm using v3.6.0 and that issue relates to the newer Context
API.
@pronebird Are you using context--either legacy or modern?
I tested the same scenario in my Electron app with modern Context
and was not able to repro. I made a separate issue (#1304) for a subset of what I mentioned here to avoid polluting this issue which may not be related to what I'm seeing. Not all the behavior I described above manifests in the minimal repro in the new issue.
@matt-tingen I use modern contexts with React 16.5, and ReactXP which is likely to rely on the old context API. The error itself does not seem to break anything. In any case, how's what you describe can be related?
@pronebird From what I've seen, modern Context
is fine. If ReactXP uses context, what you're seeing could be the same issue I demonstrate in #1304. What you're saying does sound similar. In my Electron app, the error thrown by devtools does not affect the app itself, but prevents meaningful inspection of the elements.
Have you been able to isolate what causes the error in your application?
@matt-tingen I've only reported the problem but didn't look into it. I'll see if I can catch this error with a JS debugger and find out what causes it.
React DevTools has been rewritten and recently launched a new version 4 UI. The source code for this rewrite was done in a separate repository and now lives in the main React repo (github.com/facebook/react).
Because version 4 was a total rewrite, and all issues in this repository are related to the old version 3 of the extension, I am closing all issues in this repository. If you can still reproduce this issue, or believe this feature request is still relevant, please open a new issue in the React repo: https://github.com/facebook/react/issues/new?labels=Component:%20Developer%20Tools