/ services / compact / compactWarningHook.ts
compactWarningHook.ts
 1  import { useSyncExternalStore } from 'react'
 2  import { compactWarningStore } from './compactWarningState.js'
 3  
 4  /**
 5   * React hook to subscribe to compact warning suppression state.
 6   *
 7   * Lives in its own file so that compactWarningState.ts stays React-free:
 8   * microCompact.ts imports the pure state functions, and pulling React into
 9   * that module graph would drag it into the print-mode startup path.
10   */
11  export function useCompactWarningSuppression(): boolean {
12    return useSyncExternalStore(
13      compactWarningStore.subscribe,
14      compactWarningStore.getState,
15    )
16  }