Skip to content

Commit c54bafb

Browse files
committed
Get rid of non-null assertion
1 parent c0ab165 commit c54bafb

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

sample/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>react-datetime-picker sample page</title>
77
</head>
88
<body>
9-
<div id="react-root"></div>
9+
<div id="root"></div>
1010
<script type="module" src="./index.tsx"></script>
1111
</body>
1212
</html>

sample/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ import { createRoot } from 'react-dom/client';
22

33
import Sample from './Sample.js';
44

5-
createRoot(document.getElementById('react-root')!).render(<Sample />);
5+
const root = document.getElementById('root');
6+
7+
if (!root) {
8+
throw new Error('Could not find root element');
9+
}
10+
11+
createRoot(root).render(<Sample />);

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<title>react-datetime-picker test page</title>
77
</head>
88
<body>
9-
<div id="react-root"></div>
9+
<div id="root"></div>
1010
<script type="module" src="./index.tsx"></script>
1111
</body>
1212
</html>

test/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { createRoot } from 'react-dom/client';
33

44
import Test from './Test.js';
55

6-
createRoot(document.getElementById('react-root')!).render(
6+
const root = document.getElementById('root');
7+
8+
if (!root) {
9+
throw new Error('Could not find root element');
10+
}
11+
12+
createRoot(root).render(
713
<StrictMode>
814
<Test />
915
</StrictMode>,

0 commit comments

Comments
 (0)