overleaf-cep/services/web/frontend/js/shared/hooks/use-unstable-store-sync.ts
Tim Down 132ccbc4cc Merge pull request #26583 from overleaf/td-editor-scope-values-to-context
Move scope values starting with `editor.` to contexts

GitOrigin-RevId: 7ca349ceff002228cf4e931c644c8c386eb6c597
2025-07-09 08:05:15 +00:00

11 lines
363 B
TypeScript

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