Skip to content

Commit 870cdfd

Browse files
authored
Merge pull request #464 from velopert/fix/should-not-use-window-from-render
fix: should not use window from render because of Node.js runtime
2 parents 0031228 + bd2123f commit 870cdfd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/pages/home/HomePage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import MainTemplate from '../../components/main/MainTemplate';
33
import Header from '../../components/base/Header';
44
import HomeTab from '../../components/home/HomeTab';
@@ -12,7 +12,9 @@ import FloatingHeader from '../../components/base/FloatingHeader';
1212
export type HomePageProps = {};
1313

1414
function HomePage(props: HomePageProps) {
15-
window.location.href = process.env.REACT_APP_CLIENT_V3_HOST!;
15+
useEffect(() => {
16+
window.location.href = process.env.REACT_APP_CLIENT_V3_HOST!;
17+
}, []);
1618
return (
1719
<MainTemplate>
1820
<Header />

src/pages/velog/UserPage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import styled from 'styled-components';
33
import VelogResponsive from '../../components/velog/VelogResponsive';
44
import UserProfileContainer from '../../containers/velog/UserProfileContainer';
@@ -18,8 +18,10 @@ export interface UserPageProps
1818

1919
const UserPage: React.FC<UserPageProps> = ({ match, location }) => {
2020
const { username, tab } = match.params;
21-
window.location.href = `${process.env
22-
.REACT_APP_CLIENT_V3_HOST!}/@${username}/posts`;
21+
useEffect(() => {
22+
window.location.href = `${process.env
23+
.REACT_APP_CLIENT_V3_HOST!}/@${username}/posts`;
24+
}, []);
2325

2426
return (
2527
<UserPageBlock>

0 commit comments

Comments
 (0)