Skip to content

Commit 2c8265b

Browse files
authored
docs(solid-query): add optional chaining to prevent suspense bug
1 parent b58da75 commit 2c8265b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/framework/solid/overview.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SolidJS has been gaining popularity as a fast, reactive, and declarative library
1111

1212
```tsx
1313
import { createResource, ErrorBoundary, Suspense } from 'solid-js'
14+
import { render } from 'solid-js/web'
1415

1516
function App() {
1617
const [repository] = createResource(async () => {
@@ -26,7 +27,7 @@ function App() {
2627
<ErrorBoundary fallback={<div>Something went wrong!</div>}>
2728
{/* Suspense will trigger a loading state while the data is being fetched */}
2829
<Suspense fallback={<div>Loading...</div>}>
29-
<div>{repository().updated_at}</div>
30+
<div>{repository()?.updated_at}</div>
3031
</Suspense>
3132
</ErrorBoundary>
3233
</div>
@@ -100,7 +101,7 @@ function App() {
100101
The `data` property on a query is a SolidJS resource
101102
so it will work with Suspense and transitions out of the box!
102103
*/}
103-
<div>{repositoryQuery.data.updated_at}</div>
104+
<div>{repositoryQuery.data?.updated_at}</div>
104105
</Suspense>
105106
</ErrorBoundary>
106107
</div>

0 commit comments

Comments
 (0)