-
Notifications
You must be signed in to change notification settings - Fork 47.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DevTools shows unsupported renderer version dialog (#16897)
* DevTools shows unsupported renderer version dialog * Optimistic CHANGELOG udpate
- Loading branch information
Brian Vaughn
authored
Sep 26, 2019
1 parent
84e83db
commit b6606ec
Showing
12 changed files
with
161 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
20 changes: 20 additions & 0 deletions
20
packages/react-devtools-shared/src/devtools/views/UnsupportedVersionDialog.css
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.Row { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
|
||
.Column { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.Title { | ||
font-size: var(--font-size-sans-large); | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
.ReleaseNotesLink { | ||
color: var(--color-button-active); | ||
} |
83 changes: 83 additions & 0 deletions
83
packages/react-devtools-shared/src/devtools/views/UnsupportedVersionDialog.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import React, {Fragment, useContext, useEffect, useState} from 'react'; | ||
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom'; | ||
import {ModalDialogContext} from './ModalDialog'; | ||
import {StoreContext} from './context'; | ||
import {UNSUPPORTED_VERSION_URL} from 'react-devtools-shared/src/constants'; | ||
|
||
import styles from './UnsupportedVersionDialog.css'; | ||
|
||
type DAILOG_STATE = 'dialog-not-shown' | 'show-dialog' | 'dialog-shown'; | ||
|
||
export default function UnsupportedVersionDialog(_: {||}) { | ||
const {dispatch} = useContext(ModalDialogContext); | ||
const store = useContext(StoreContext); | ||
const [state, setState] = useState<DAILOG_STATE>('dialog-not-shown'); | ||
|
||
useEffect( | ||
() => { | ||
if (state === 'dialog-not-shown') { | ||
const showDialog = () => { | ||
batchedUpdates(() => { | ||
setState('show-dialog'); | ||
dispatch({ | ||
canBeDismissed: true, | ||
type: 'SHOW', | ||
content: <DialogContent />, | ||
}); | ||
}); | ||
}; | ||
|
||
if (store.unsupportedRendererVersionDetected) { | ||
showDialog(); | ||
} else { | ||
store.addListener('unsupportedRendererVersionDetected', showDialog); | ||
return () => { | ||
store.removeListener( | ||
'unsupportedRendererVersionDetected', | ||
showDialog, | ||
); | ||
}; | ||
} | ||
} | ||
}, | ||
[state, store], | ||
); | ||
|
||
return null; | ||
} | ||
|
||
function DialogContent(_: {||}) { | ||
return ( | ||
<Fragment> | ||
<div className={styles.Row}> | ||
<div> | ||
<div className={styles.Title}>Unsupported React version detected</div> | ||
<p> | ||
This version of React DevTools supports React DOM v15+ and React | ||
Native v61+. | ||
</p> | ||
<p> | ||
In order to use DevTools with an older version of React, you'll need | ||
to{' '} | ||
<a | ||
className={styles.ReleaseNotesLink} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
href={UNSUPPORTED_VERSION_URL}> | ||
install an older version of the extension | ||
</a>. | ||
</p> | ||
</div> | ||
</div> | ||
</Fragment> | ||
); | ||
} |
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
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