mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 15:49:01 +02:00
205cfbe816
[web] Enable Cypress test for creating new subscription GitOrigin-RevId: c17efbeb6a29d8e757729cddffef46faf054da70
25 lines
536 B
TypeScript
25 lines
536 B
TypeScript
import { useCallback, useMemo } from 'react'
|
|
import useIsMounted from './use-is-mounted'
|
|
import { location } from '@/shared/components/location'
|
|
|
|
export const useLocation = () => {
|
|
const isMounted = useIsMounted()
|
|
|
|
const assign = useCallback(
|
|
url => {
|
|
if (isMounted.current) {
|
|
location.assign(url)
|
|
}
|
|
},
|
|
[isMounted]
|
|
)
|
|
|
|
const reload = useCallback(() => {
|
|
if (isMounted.current) {
|
|
location.reload()
|
|
}
|
|
}, [isMounted])
|
|
|
|
return useMemo(() => ({ assign, reload }), [assign, reload])
|
|
}
|