Open History to see the last commit
1'use client'
2β
3import { useHydrated } from '@tanstack/react-router'
4import * as React from 'react'
5import styles from './ClientWidgetB.module.css'
6β
7/**
8 * Client widget B - passed via children slot to server component.
9 * Uses CSS module B with teal theme.
10 */
11export function ClientWidgetB({ title }: { title: string }) {
12 const [active, setActive] = React.useState(false)
13 const isHydrated = useHydrated()
14β
15 return (
16 <div className={styles.widget} data-testid="client-widget-b">
17 <div className={styles.header}>
18 <span className={styles.badge} data-testid="client-widget-b-badge">
19 CLIENT B (Slot)
20 </span>
21 </div>
22 <h3 className={styles.title} data-testid="client-widget-b-title">
23 {title}
24 </h3>
25 <p className={styles.content}>Passed via children slot to RSC.</p>
26 <button
27 className={`${styles.toggleButton} ${active ? styles.active : ''}`}
28 onClick={() => setActive((a) => !a)}
29 data-testid="client-widget-b-toggle"
30 disabled={!isHydrated}
31 >
32 {active ? 'Active' : 'Inactive'}
33 </button>
34 </div>
35 )
36}