-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathRouteSelector.tsx
More file actions
59 lines (47 loc) · 1.5 KB
/
Copy pathRouteSelector.tsx
File metadata and controls
59 lines (47 loc) · 1.5 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
import App from './App';
import { TestMentions } from './testScreens/TestMentions';
import { TestLinks } from './testScreens/TestLinks';
import { TestSetSelection } from './testScreens/TestSetSelection';
import { VisualRegression } from './testScreens/VisualRegression';
import { TestSubmitProps } from './testScreens/TestSubmitProps';
import { TestEnrichedText } from './testScreens/TestEnrichedText';
import { TestEllipsize } from './testScreens/TestEllipsize';
import { TestRenderCycle } from './testScreens/TestRenderCycle';
import { useEffect, useState } from 'react';
export default function RouteSelector() {
const [path, setPath] = useState(window.location.pathname);
useEffect(() => {
const onPopState = () => {
setPath(window.location.pathname);
};
window.addEventListener('popstate', onPopState);
return () => {
window.removeEventListener('popstate', onPopState);
};
}, []);
if (path === '/test-set-selection') {
return <TestSetSelection />;
}
if (path === '/test-links') {
return <TestLinks />;
}
if (path === '/visual-regression') {
return <VisualRegression />;
}
if (path === '/test-submit-props') {
return <TestSubmitProps />;
}
if (path === '/test-mentions') {
return <TestMentions />;
}
if (path === '/test-enriched-text') {
return <TestEnrichedText />;
}
if (path === '/test-ellipsize') {
return <TestEllipsize />;
}
if (path === '/test-render-cycle') {
return <TestRenderCycle />;
}
return <App />;
}