hooks/usePosts.js
import {useEffect, useState, useCallback} from 'react'; import {getNewerPosts, getOlderPosts, getPosts, PAGE_SIZE} from '../lib/posts'; export default function (userId) { ( ) const onRefresh = useCallback(async () => { if (posts posts.length == 0 refreshing) { return; } const firstPost posts[0]; (true); const newerPosts await (firstPost.id, userId); (false); if (newerPosts.length == 0) { return; } (newerPosts. (posts)); }, [posts, userId, refreshing]); ( )