Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

EnhancedNestedWidget.tsx

33 lines893 Bytes

1import { createSignal, onMount } from 'solid-js'
2import { Hydrate } from '@tanstack/solid-start'
3import { interaction, media } from '@tanstack/solid-start/hydration'
4​
5function CrossFileNestedButton() {
6 const [count, setCount] = createSignal(0)
7 const [hydrated, setHydrated] = createSignal(false)
8​
9 onMount(() => {
10 setHydrated(true)
11 })
12​
13 return (
14 <button
15 data-testid="enhanced-cross-file-nested-button"
16 data-hydrated={hydrated() ? 'true' : 'false'}
17 onClick={() => setCount((prev) => prev + 1)}
18 >
19 cross-file nested child:{' '}
20 <span data-testid="enhanced-cross-file-nested-count">{count()}</span>
21 </button>
22 )
24​
25export function EnhancedNestedWidget() {
26 return (
27 <Hydrate when={media('(max-width: 1px)')}>
28 <Hydrate when={interaction({ events: 'click' })}>
29 <CrossFileNestedButton />
30 </Hydrate>
31 </Hydrate>
32 )