-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tsx
51 lines (44 loc) · 1.4 KB
/
main.tsx
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
import React from 'react';
import { render } from 'react-dom';
import { TestProviderWeb } from './TestProviderWeb';
import { TestProviderCloud } from './TestProviderCloud';
type TProvider = 'web' | 'cloud';
const initialProvider = location.href.includes('provider-cloud') ? 'cloud' : 'web';
function deleteFrames(): void {
const frames = window.document.getElementsByTagName('iframe');
for (let i = 0; i < frames.length; i++) {
window.document.body.removeChild(frames[i]);
}
}
function TestApp(): React.ReactElement {
const [provider, setProvider] = React.useState<TProvider>(initialProvider);
const setProviderWeb = React.useCallback((): void => {
setProvider('web');
deleteFrames();
}, []);
const setProviderCloud = React.useCallback((): void => {
setProvider('cloud');
deleteFrames();
}, []);
return (
<>
<div>
<button
onClick={setProviderWeb}
>
Provider Web
</button>
<button
onClick={setProviderCloud}
>
Provider Cloud
</button>
</div>
{provider === 'web' ?
<TestProviderWeb /> :
<TestProviderCloud />
}
</>
);
}
render(<TestApp />, document.getElementById('root'));