File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const ShowPage = () => {
9
9
const { id } = useParams ( ) ;
10
10
const [ post , setPost ] = useState ( null ) ;
11
11
const [ loading , setLoading ] = useState ( true ) ;
12
+ const [ timer , setTimer ] = useState ( 0 ) ;
12
13
const isLoggedIn = useSelector ( state => state . auth . isLoggedIn ) ;
13
14
14
15
const getPost = ( id ) => {
@@ -18,6 +19,17 @@ const ShowPage = () => {
18
19
} )
19
20
} ;
20
21
22
+ useEffect ( ( ) => {
23
+ const interval = setInterval ( ( ) => {
24
+ console . log ( 'hello' )
25
+ setTimer ( prev => prev + 1 ) ;
26
+ } , 1000 ) ;
27
+
28
+ return ( ) => {
29
+ clearInterval ( interval ) ;
30
+ }
31
+ } , [ ] ) ;
32
+
21
33
useEffect ( ( ) => {
22
34
getPost ( id )
23
35
} , [ id ] )
@@ -33,7 +45,7 @@ const ShowPage = () => {
33
45
return (
34
46
< div >
35
47
< div className = "d-flex" >
36
- < h1 className = "flex-grow-1" > { post . title } </ h1 >
48
+ < h1 className = "flex-grow-1" > { post . title } ( { timer } 초) </ h1 >
37
49
{ isLoggedIn && < div >
38
50
< Link
39
51
className = "btn btn-primary"
You can’t perform that action at this time.
0 commit comments