From 51606bb16e139a7e25960bec4101cf0c28fdabe6 Mon Sep 17 00:00:00 2001 From: grzdev Date: Sun, 1 Mar 2026 22:24:16 +0100 Subject: [PATCH] fix(examples): guard missing mount targets in solid examples --- examples/solid/basic-graphql-request/src/index.tsx | 5 ++++- examples/solid/basic/src/index.tsx | 5 ++++- examples/solid/default-query-function/src/index.tsx | 5 ++++- examples/solid/offline/src/index.tsx | 5 ++++- examples/solid/simple/src/index.tsx | 5 ++++- examples/solid/solid-start-streaming/src/entry-client.tsx | 5 ++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/solid/basic-graphql-request/src/index.tsx b/examples/solid/basic-graphql-request/src/index.tsx index c01fb9bffa3..96d4b1e19f7 100644 --- a/examples/solid/basic-graphql-request/src/index.tsx +++ b/examples/solid/basic-graphql-request/src/index.tsx @@ -170,4 +170,7 @@ function Post(props: { postId: number; setPostId: Setter }) { ) } -render(() => , document.getElementById('root') as HTMLElement) +const root = document.getElementById('root') +if (!root) throw new Error('Missing #root element') + +render(() => , root) diff --git a/examples/solid/basic/src/index.tsx b/examples/solid/basic/src/index.tsx index eaed876348f..f4f32384677 100644 --- a/examples/solid/basic/src/index.tsx +++ b/examples/solid/basic/src/index.tsx @@ -151,4 +151,7 @@ const App: Component = () => { ) } -render(() => , document.getElementById('root') as HTMLElement) +const root = document.getElementById('root') +if (!root) throw new Error('Missing #root element') + +render(() => , root) diff --git a/examples/solid/default-query-function/src/index.tsx b/examples/solid/default-query-function/src/index.tsx index f05ad7ac7ed..65d9aa7beae 100644 --- a/examples/solid/default-query-function/src/index.tsx +++ b/examples/solid/default-query-function/src/index.tsx @@ -136,4 +136,7 @@ function Post(props: { postId: number; setPostId: Setter }) { ) } -render(() => , document.getElementById('root') as HTMLElement) +const root = document.getElementById('root') +if (!root) throw new Error('Missing #root element') + +render(() => , root) diff --git a/examples/solid/offline/src/index.tsx b/examples/solid/offline/src/index.tsx index ba6638f7b47..0549de54bb9 100644 --- a/examples/solid/offline/src/index.tsx +++ b/examples/solid/offline/src/index.tsx @@ -5,11 +5,14 @@ import { worker } from './api' worker.start() +const root = document.getElementById('root') +if (!root) throw new Error('Missing #root element') + render( () => (
), - document.getElementById('root')!, + root, ) diff --git a/examples/solid/simple/src/index.tsx b/examples/solid/simple/src/index.tsx index 26534c9953d..d159537f650 100644 --- a/examples/solid/simple/src/index.tsx +++ b/examples/solid/simple/src/index.tsx @@ -49,4 +49,7 @@ function Example() { ) } -render(() => , document.getElementById('root') as HTMLElement) +const root = document.getElementById('root') +if (!root) throw new Error('Missing #root element') + +render(() => , root) diff --git a/examples/solid/solid-start-streaming/src/entry-client.tsx b/examples/solid/solid-start-streaming/src/entry-client.tsx index 46acd52f93b..27827467ce1 100644 --- a/examples/solid/solid-start-streaming/src/entry-client.tsx +++ b/examples/solid/solid-start-streaming/src/entry-client.tsx @@ -1,4 +1,7 @@ // @refresh reload import { mount, StartClient } from '@solidjs/start/client' -mount(() => , document.getElementById('app')!) +const app = document.getElementById('app') +if (!app) throw new Error('Missing #app element') + +mount(() => , app)