File tree 2 files changed +6
-1
lines changed
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
4
4
import { Post } from '@/app/types/Post' ;
5
5
import PostList from '@/app/entities/post/list/PostList' ;
6
6
import SearchSection from '@/app/entities/post/list/SearchSection' ;
7
+ import { debounce } from 'lodash' ;
7
8
8
9
const BlogList = ( ) => {
9
10
const [ posts , setPosts ] = useState < Post [ ] > ( ) ;
@@ -20,8 +21,10 @@ const BlogList = () => {
20
21
setLoading ( false ) ;
21
22
} ;
22
23
24
+ const debouncedGetPosts = debounce ( getPosts , 500 ) ;
25
+
23
26
useEffect ( ( ) => {
24
- getPosts ( query ) ;
27
+ debouncedGetPosts ( query ) ;
25
28
} , [ query ] ) ;
26
29
27
30
return (
Original file line number Diff line number Diff line change 12
12
},
13
13
"dependencies" : {
14
14
"@next/third-parties" : " ^15.1.2" ,
15
+ "@types/lodash" : " ^4.17.13" ,
15
16
"@uiw/react-md-editor" : " ^4.0.4" ,
16
17
"@vercel/blob" : " ^0.27.0" ,
17
18
"axios" : " ^1.7.9" ,
19
+ "lodash" : " ^4.17.21" ,
18
20
"mongoose" : " ^8.9.0" ,
19
21
"next" : " 14.2.13" ,
20
22
"next-auth" : " ^4.24.11" ,
You can’t perform that action at this time.
0 commit comments