Fix post-list linting
This commit is contained in:
parent
19c5725847
commit
e4b215b7a8
1 changed files with 16 additions and 15 deletions
|
@ -31,32 +31,33 @@ const PostList = ({
|
||||||
const [search, setSearchValue] = useState("")
|
const [search, setSearchValue] = useState("")
|
||||||
const [posts, setPosts] = useState<PostWithFiles[]>(initialPosts)
|
const [posts, setPosts] = useState<PostWithFiles[]>(initialPosts)
|
||||||
const [searching, setSearching] = useState(false)
|
const [searching, setSearching] = useState(false)
|
||||||
const [hasMorePosts, setHasMorePosts] = useState(morePosts)
|
const [hasMorePosts] = useState(morePosts)
|
||||||
const { setToast } = useToasts()
|
const { setToast } = useToasts()
|
||||||
|
|
||||||
const loadMoreClick = useCallback(
|
const loadMoreClick = useCallback(
|
||||||
(e: React.MouseEvent<HTMLButtonElement>) => {
|
(e: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (hasMorePosts) {
|
if (hasMorePosts) {
|
||||||
|
// eslint-disable-next-line no-inner-declarations
|
||||||
async function fetchPosts() {
|
async function fetchPosts() {
|
||||||
const res = await fetch(`/server-api/posts/mine`, {
|
// const res = await fetch(`/api/posts/mine`, {
|
||||||
method: "GET",
|
// method: "GET",
|
||||||
headers: {
|
// headers: {
|
||||||
"Content-Type": "application/json",
|
// "Content-Type": "application/json",
|
||||||
"x-page": `${posts.length / 10 + 1}`
|
// "x-page": `${posts.length / 10 + 1}`
|
||||||
},
|
// },
|
||||||
next: {
|
// next: {
|
||||||
revalidate: 10
|
// revalidate: 10
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
const json = await res.json()
|
// const json = await res.json()
|
||||||
setPosts([...posts, ...json.posts])
|
// setPosts([...posts, ...json.posts])
|
||||||
setHasMorePosts(json.morePosts)
|
// setHasMorePosts(json.morePosts)
|
||||||
}
|
}
|
||||||
fetchPosts()
|
fetchPosts()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[posts, hasMorePosts]
|
[hasMorePosts]
|
||||||
)
|
)
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: address this
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: address this
|
||||||
|
|
Loading…
Reference in a new issue