Open History to see the last commit
1import * as React from 'react'
2import { Hydrate } from '@tanstack/react-start'
3import { interaction, media } from '@tanstack/react-start/hydration'
4β
5function CrossFileNestedButton() {
6 const [count, setCount] = React.useState(0)
7 const [hydrated, setHydrated] = React.useState(false)
8β
9 React.useEffect(() => {
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 )
23}
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 )
33}