mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 22:26:57 +01:00
Don't need useLocation when in compose pop-out
This commit is contained in:
parent
37fc65b47a
commit
e0d50168fd
1 changed files with 5 additions and 2 deletions
|
@ -11,7 +11,10 @@ import states from '../utils/states';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Link = (props) => {
|
const Link = (props) => {
|
||||||
const routerLocation = useLocation();
|
let routerLocation;
|
||||||
|
try {
|
||||||
|
routerLocation = useLocation();
|
||||||
|
} catch (e) {}
|
||||||
let hash = (location.hash || '').replace(/^#/, '').trim();
|
let hash = (location.hash || '').replace(/^#/, '').trim();
|
||||||
if (hash === '') hash = '/';
|
if (hash === '') hash = '/';
|
||||||
const isActive = hash === props.to;
|
const isActive = hash === props.to;
|
||||||
|
@ -21,7 +24,7 @@ const Link = (props) => {
|
||||||
{...props}
|
{...props}
|
||||||
class={`${props.class || ''} ${isActive ? 'is-active' : ''}`}
|
class={`${props.class || ''} ${isActive ? 'is-active' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
states.prevLocation = routerLocation;
|
if (routerLocation) states.prevLocation = routerLocation;
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue