File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -367,12 +367,13 @@ const PostViewer: React.FC<PostViewerProps> = ({
367
367
/>
368
368
</ UserProfileWrapper >
369
369
< LinkedPostList linkedPosts = { post . linked_posts } />
370
- < RelatedPost />
370
+ < RelatedPost type = "desktop" />
371
371
< PostComments
372
372
count = { post . comments_count }
373
373
comments = { post . comments }
374
374
postId = { post . id }
375
375
/>
376
+ < RelatedPost type = "mobile" />
376
377
</ PostViewerProvider >
377
378
) ;
378
379
} ;
Original file line number Diff line number Diff line change 1
- import React , { useEffect } from 'react' ;
1
+ import React , { useEffect , useState } from 'react' ;
2
2
import styled from 'styled-components' ;
3
3
import VelogResponsive from '../../components/velog/VelogResponsive' ;
4
4
5
- function RelatedPost ( ) {
5
+ type RelatedPostProps = {
6
+ type : 'desktop' | 'mobile' ;
7
+ } ;
8
+ function RelatedPost ( { type } : RelatedPostProps ) {
9
+ const [ visible , setVisible ] = useState ( true ) ;
6
10
useEffect ( ( ) => {
11
+ const width = window . innerWidth ;
12
+ if ( type === 'desktop' && width < 468 ) {
13
+ setVisible ( false ) ;
14
+ return ;
15
+ }
16
+ if ( type === 'mobile' && width >= 468 ) {
17
+ setVisible ( false ) ;
18
+ return ;
19
+ }
7
20
( window . adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ;
8
- } , [ ] ) ;
21
+ } , [ type ] ) ;
22
+
23
+ if ( ! visible ) return null ;
9
24
10
25
return (
11
26
< Wrapper >
You can’t perform that action at this time.
0 commit comments