MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / useBlocker

Function useBlocker

packages/ui/src/utils/usePrompt.js:6–26  ·  view source on GitHub ↗
(blocker, when = true)

Source from the content-addressed store, hash-verified

4// https://stackoverflow.com/questions/71572678/react-router-v-6-useprompt-typescript
5
6export function useBlocker(blocker, when = true) {
7 const { navigator } = useContext(NavigationContext)
8
9 useEffect(() => {
10 if (!when) return
11
12 const unblock = navigator.block((tx) => {
13 const autoUnblockingTx = {
14 ...tx,
15 retry() {
16 unblock()
17 tx.retry()
18 }
19 }
20
21 blocker(autoUnblockingTx)
22 })
23
24 return unblock
25 }, [navigator, blocker, when])
26}
27
28export function usePrompt(message, when = true) {
29 const blocker = useCallback(

Callers 1

usePromptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected