diff --git a/examples/react/shadow-dom/src/main.tsx b/examples/react/shadow-dom/src/main.tsx
index cf1b9e53493..2f7ea2400a1 100644
--- a/examples/react/shadow-dom/src/main.tsx
+++ b/examples/react/shadow-dom/src/main.tsx
@@ -6,30 +6,29 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { DogList } from './DogList'
const appRoot = document.getElementById('root')
+if (!appRoot) throw new Error('Missing #root element')
-if (appRoot) {
- const queryClient = new QueryClient()
- const shadowRoot = appRoot.attachShadow({ mode: 'open' })
- const root = ReactDOM.createRoot(shadowRoot)
+const queryClient = new QueryClient()
+const shadowRoot = appRoot.attachShadow({ mode: 'open' })
+const root = ReactDOM.createRoot(shadowRoot)
- root.render(
-
-
-
-
Dog Breeds
-
-
-
-
- ,
- )
-}
+root.render(
+
+
+
+
Dog Breeds
+
+
+
+
+ ,
+)