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 cf1dade commit 702b4fd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</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 @@ -7,7 +7,7 @@
</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 702b4fd

Please sign in to comment.