Skip to content

Commit

Permalink
fix: ssr hide document
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 30, 2020
1 parent ed12379 commit 713bbb7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions ui/blocks/src/PageContainer/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ export const PageContainer: FC<PageContainerProps> = forwardRef(
{ children, variant, wrapper: Wrapper = Container, ...rest },
ref: React.Ref<HTMLDivElement>,
) => {
const pageURL =
(typeof window !== 'undefined' &&
window.location !== window.parent.location &&
window.parent.location
? window.parent.location.href
: document.location.href) || '';
const url = new URL(pageURL);
useEffect(() => {
try {
const pageURL =
(typeof window !== 'undefined' &&
window.location !== window.parent.location &&
window.parent.location
? window.parent.location.href
: document.location.href) || '';
const url = new URL(pageURL);

const scrollId = url.hash ? url.hash.substring(1) : undefined;
if (scrollId) {
const element = document.getElementById(scrollId);
Expand All @@ -61,7 +62,7 @@ export const PageContainer: FC<PageContainerProps> = forwardRef(
}
}
} catch (err) {}
}, [url.hash]);
}, []);
const theme = useTheme();
return (
<Box
Expand Down

0 comments on commit 713bbb7

Please sign in to comment.