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