mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 11:24:35 +00:00
chore(web): move hooks to hooks folder
This commit is contained in:
2
web/src/utils/hooks/index.ts
Normal file
2
web/src/utils/hooks/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './usePrompt'
|
||||
export * from './useStateWithCallback'
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useCallback, useContext } from 'react'
|
||||
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom'
|
||||
import { History, Blocker, Transition } from 'history'
|
||||
|
||||
function useBlocker(blocker: Blocker, when = true) {
|
||||
const useBlocker = (blocker: Blocker, when = true) => {
|
||||
const navigator = useContext(NavigationContext).navigator as History
|
||||
|
||||
useEffect(() => {
|
||||
@@ -24,7 +24,7 @@ function useBlocker(blocker: Blocker, when = true) {
|
||||
}, [navigator, blocker, when])
|
||||
}
|
||||
|
||||
export default function usePrompt(message: string, when = true) {
|
||||
export const usePrompt = (message: string, when = true) => {
|
||||
const blocker = useCallback(
|
||||
(tx) => {
|
||||
if (window.confirm(message)) tx.retry()
|
||||
Reference in New Issue
Block a user