latex-ub/services/web/frontend/js/features/ide-react/hooks/use-has-linting-error.ts
2025-05-05 12:24:05 +00:00

19 lines
564 B
TypeScript

import useEventListener from '@/shared/hooks/use-event-listener'
import { useLocalCompileContext } from '@/shared/context/local-compile-context'
import { useCallback } from 'react'
export function useHasLintingError() {
const { setHasLintingError } = useLocalCompileContext()
// Listen for editor:lint event from CM6 linter and keep compile context
// up to date
useEventListener(
'editor:lint',
useCallback(
(event: CustomEvent) => {
setHasLintingError(event.detail.hasLintingError)
},
[setHasLintingError]
)
)
}