-
Notifications
You must be signed in to change notification settings - Fork 50.9k
Expand file tree
/
Copy pathUnsupportedVersionDialog.js
More file actions
80 lines (72 loc) · 2.2 KB
/
UnsupportedVersionDialog.js
File metadata and controls
80 lines (72 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* Copyright (c) Meta Platforms, Inc. and 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 * as React from 'react';
import {Fragment, useContext, useEffect, useState} from 'react';
import {ModalDialogContext} from './ModalDialog';
import {StoreContext} from './context';
import {UNSUPPORTED_VERSION_URL} from '../constants';
import styles from './UnsupportedVersionDialog.css';
type DAILOG_STATE = 'dialog-not-shown' | 'show-dialog' | 'dialog-shown';
export default function UnsupportedVersionDialog(_: {}): null {
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 = () => {
setState('show-dialog');
dispatch({
canBeDismissed: true,
id: 'UnsupportedVersionDialog',
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>
);
}