• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LouisBrunner / dnd-multi-backend / 3665211237

pending completion
3665211237

push

github

Louis Brunner
fix: remove Node 14 builds (need npm 7 and above) and improve npm caching

284 of 376 branches covered (75.53%)

Branch coverage included in aggregate %.

692 of 710 relevant lines covered (97.46%)

12.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.36
/packages/react-dnd-multi-backend/src/hooks/useObservePreviews.ts
1
import { useState, useEffect, useContext } from 'react'
5✔
2
import { DndContext, DndContextType } from 'react-dnd'
5✔
3
import { MultiBackendSwitcher } from 'dnd-multi-backend'
5✔
4

5✔
5
export const useObservePreviews = (): boolean => {
5✔
6
  const [enabled, setEnabled] = useState<boolean>(false)
5✔
7
  const dndContext = useContext<DndContextType>(DndContext)
5✔
8

9
  useEffect(() => {
5✔
10
    const backend = dndContext?.dragDropManager?.getBackend() as MultiBackendSwitcher
5!
11

5✔
12
    const observer = {
5!
13
      backendChanged: (cbackend: MultiBackendSwitcher) => {
21✔
14
        setEnabled(cbackend.previewEnabled())
15
      },
5✔
16
    }
17

5✔
18
    setEnabled(backend.previewEnabled())
5✔
19

5✔
20
    backend.previewsList().register(observer)
21✔
21
    return () => {
22
      backend.previewsList().unregister(observer)
5✔
23
    }
5✔
24
  }, [dndContext, dndContext.dragDropManager])
5✔
25

5✔
26
  return enabled
21✔
27
}
21✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc