From e0d50168fd4bc708cd0b1541080adf81ada11646 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 21 Jan 2023 13:21:57 +0800 Subject: [PATCH] Don't need useLocation when in compose pop-out --- src/components/link.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/link.jsx b/src/components/link.jsx index 30659f46..3dee227d 100644 --- a/src/components/link.jsx +++ b/src/components/link.jsx @@ -11,7 +11,10 @@ import states from '../utils/states'; */ const Link = (props) => { - const routerLocation = useLocation(); + let routerLocation; + try { + routerLocation = useLocation(); + } catch (e) {} let hash = (location.hash || '').replace(/^#/, '').trim(); if (hash === '') hash = '/'; const isActive = hash === props.to; @@ -21,7 +24,7 @@ const Link = (props) => { {...props} class={`${props.class || ''} ${isActive ? 'is-active' : ''}`} onClick={() => { - states.prevLocation = routerLocation; + if (routerLocation) states.prevLocation = routerLocation; }} /> );