pages235/src/react/utils.ts
Vitaly a72ca11a0e refactor: split AppStatus into components
fix: change top-level options buttons order
2023-10-23 02:42:33 +03:00

23 lines
546 B
TypeScript

import { useSnapshot } from 'valtio'
import { useEffect, useRef } from 'react'
import { activeModalStack } from '../globalState'
export const useIsModalActive = (modal: string) => {
return useSnapshot(activeModalStack).at(-1)?.reactType === modal
}
export function useDidUpdateEffect (fn, inputs) {
const isMountingRef = useRef(false)
useEffect(() => {
isMountingRef.current = true
}, [])
useEffect(() => {
if (isMountingRef.current) {
isMountingRef.current = false
} else {
return fn()
}
}, inputs)
}