use-unstable-store-sync.ts 363 B

1234567891011
  1. import { useIdeContext } from '@/shared/context/ide-context'
  2. import { useEffect } from 'react'
  3. export function useUnstableStoreSync<T = any>(path: string, value: T) {
  4. const { unstableStore } = useIdeContext()
  5. // Update the unstable store whenever the value changes
  6. useEffect(() => {
  7. unstableStore.set(path, value)
  8. }, [unstableStore, path, value])
  9. }