forked from facebook/react
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
71 lines (58 loc) · 2.08 KB
/
index.js
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
/** @flow */
// This test harness mounts each test app as a separate root to test multi-root applications.
import {createElement} from 'react';
import {
// $FlowFixMe Flow does not yet know about createRoot()
unstable_createRoot as createRoot,
} from 'react-dom';
import DeeplyNestedComponents from './DeeplyNestedComponents';
import Iframe from './Iframe';
import EditableProps from './EditableProps';
import ElementTypes from './ElementTypes';
import Hydration from './Hydration';
import InspectableElements from './InspectableElements';
import InteractionTracing from './InteractionTracing';
import PriorityLevels from './PriorityLevels';
import ReactNativeWeb from './ReactNativeWeb';
import ToDoList from './ToDoList';
import Toggle from './Toggle';
import SuspenseTree from './SuspenseTree';
import {ignoreErrors, ignoreWarnings} from './console';
import './styles.css';
// DevTools intentionally tests compatibility with certain legacy APIs.
// Suppress their error messages in the local dev shell,
// because they might mask other more serious error messages.
ignoreErrors([
'Warning: Legacy context API',
'Warning: Unsafe lifecycle methods',
'Warning: %s is deprecated in StrictMode.', // findDOMNode
]);
ignoreWarnings(['Warning: componentWillReceiveProps has been renamed']);
const roots = [];
function mountHelper(App) {
const container = document.createElement('div');
((document.body: any): HTMLBodyElement).appendChild(container);
const root = createRoot(container);
root.render(createElement(App));
roots.push(root);
}
function mountTestApp() {
mountHelper(ToDoList);
mountHelper(InteractionTracing);
mountHelper(InspectableElements);
mountHelper(Hydration);
mountHelper(ElementTypes);
mountHelper(EditableProps);
mountHelper(PriorityLevels);
mountHelper(ReactNativeWeb);
mountHelper(Toggle);
mountHelper(SuspenseTree);
mountHelper(DeeplyNestedComponents);
mountHelper(Iframe);
}
function unmountTestApp() {
roots.forEach(root => root.unmount());
}
mountTestApp();
window.parent.mountTestApp = mountTestApp;
window.parent.unmountTestApp = unmountTestApp;