Skip to content

Commit

Permalink
Get rid of non-null assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Apr 17, 2024
1 parent 12a61f2 commit 043b0e4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sample/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-calendar sample page</title>
</head>
<body>
<div id="react-root"></div>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
8 changes: 7 additions & 1 deletion sample/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ import { createRoot } from 'react-dom/client';

import Sample from './Sample.js';

createRoot(document.getElementById('react-root')!).render(<Sample />);
const root = document.getElementById('root');

if (!root) {
throw new Error('Could not find root element');
}

createRoot(root).render(<Sample />);
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>react-calendar test page</title>
</head>
<body>
<div id="react-root"></div>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
8 changes: 7 additions & 1 deletion test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { createRoot } from 'react-dom/client';

import Test from './Test.js';

createRoot(document.getElementById('react-root')!).render(
const root = document.getElementById('root');

if (!root) {
throw new Error('Could not find root element');
}

createRoot(root).render(
<StrictMode>
<Test />
</StrictMode>,
Expand Down

0 comments on commit 043b0e4

Please sign in to comment.