-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
WIP: Show unsupported screen in dev tools for React version < 15.0.0 #16720
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,8 +55,9 @@ function createPanelIfReactLoaded() { | |
} | ||
|
||
chrome.devtools.inspectedWindow.eval( | ||
'window.__REACT_DEVTOOLS_GLOBAL_HOOK__ && window.__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.size > 0', | ||
function(pageHasReact, error) { | ||
'window.__REACT_DEVTOOLS_GLOBAL_HOOK__ && window.__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers', | ||
function(renderers, error) { | ||
const pageHasReact = renderers && renderers.size > 0; | ||
if (!pageHasReact || panelCreated) { | ||
return; | ||
} | ||
|
@@ -130,6 +131,7 @@ function createPanelIfReactLoaded() { | |
isProfiling, | ||
supportsReloadAndProfile: isChrome, | ||
supportsProfiling, | ||
supportsReact: renderers.get(1) && !!renderers.get(1).ComponentTree, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above comment. I don't think this belongs as a store capability, so this can be reverted 😄 |
||
}); | ||
store.profilerStore.profilingData = profilingData; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* @flow | ||
*/ | ||
|
||
import React, {Suspense} from 'react'; | ||
import React, {Suspense, useContext} from 'react'; | ||
import Tree from './Tree'; | ||
import SelectedElement from './SelectedElement'; | ||
import {InspectedElementContextController} from './InspectedElementContext'; | ||
|
@@ -17,29 +17,36 @@ import portaledContent from '../portaledContent'; | |
import {ModalDialog} from '../ModalDialog'; | ||
import SettingsModal from 'react-devtools-shared/src/devtools/views/Settings/SettingsModal'; | ||
import {SettingsModalContextController} from 'react-devtools-shared/src/devtools/views/Settings/SettingsModalContext'; | ||
import {StoreContext} from '../context'; | ||
|
||
import styles from './Components.css'; | ||
|
||
function Components(_: {||}) { | ||
const {supportsReact} = useContext(StoreContext); | ||
|
||
// TODO Flex wrappers below should be user resizable. | ||
return ( | ||
<SettingsModalContextController> | ||
<OwnersListContextController> | ||
<InspectedElementContextController> | ||
<div className={styles.Components}> | ||
<div className={styles.TreeWrapper}> | ||
<Tree /> | ||
</div> | ||
<div className={styles.SelectedElementWrapper}> | ||
<NativeStyleContextController> | ||
<Suspense fallback={<Loading />}> | ||
<SelectedElement /> | ||
</Suspense> | ||
</NativeStyleContextController> | ||
{supportsReact ? ( | ||
<div className={styles.Components}> | ||
<div className={styles.TreeWrapper}> | ||
<Tree /> | ||
</div> | ||
<div className={styles.SelectedElementWrapper}> | ||
<NativeStyleContextController> | ||
<Suspense fallback={<Loading />}> | ||
<SelectedElement /> | ||
</Suspense> | ||
</NativeStyleContextController> | ||
</div> | ||
<ModalDialog /> | ||
<SettingsModal /> | ||
</div> | ||
<ModalDialog /> | ||
<SettingsModal /> | ||
</div> | ||
) : ( | ||
<UnsupportedReactVersion /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should use the |
||
)} | ||
</InspectedElementContextController> | ||
</OwnersListContextController> | ||
</SettingsModalContextController> | ||
|
@@ -50,4 +57,15 @@ function Loading() { | |
return <div className={styles.Loading}>Loading...</div>; | ||
} | ||
|
||
function UnsupportedReactVersion() { | ||
return ( | ||
<div className={styles.Column}> | ||
<div className={styles.Header}>Unsupported React version.</div> | ||
<p className={styles.Paragraph}> | ||
React DevTools support requires a development build of React v15.0+. | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default portaledContent(Components); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this param name is a bit confusing. React DevTools always "support React" 😄 We just want to detect an unsupported version.
I think this probably doesn't belong as a store capability.