1
0
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:
2022-07-26 23:14:29 +05:00
parent 83d819df53
commit 0a780697da
2 changed files with 4 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
export * from './usePrompt'
export * from './useStateWithCallback'

View File

@@ -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()