mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
205cfbe816
[web] Enable Cypress test for creating new subscription GitOrigin-RevId: c17efbeb6a29d8e757729cddffef46faf054da70
24 lines
536 B
TypeScript
24 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])
|
|
}
|