Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Cannot read property 'sub' of undefined when navigating to plain-text pages #17848

Merged
Next Next commit
Fix Cannot read property 'sub' of undefined when navigating to plain-…
…text pages
  • Loading branch information
wfnuser committed Jan 15, 2020
commit 0aafe38206b42bc6d0fa028f9993d7deef43bb03
2 changes: 1 addition & 1 deletion packages/react-devtools-extensions/src/injectGlobalHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if (sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') {

// Inject a __REACT_DEVTOOLS_GLOBAL_HOOK__ global for React to interact with.
// Only do this for HTML documents though, to avoid e.g. breaking syntax highlighting for XML docs.
if (document.contentType === 'text/html') {
if (['text/html', 'text/plain'].includes(document.contentType)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right approach.

Injecting the hook into a plain text file wouldn't serve a purpose, since there's no React script running in such a file. Also it would not fix the problem for other non-HTML document types (e.g. text/json, application/json)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make the suggested change later in the day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was on Chinese Lunar Year vocation in the past several days. I'm working on it now...

injectCode(
';(' +
installHook.toString() +
Expand Down