toss / suspensive

All in one for React Suspense
https://suspensive.org
MIT License
540 stars 52 forks source link

[Feature]: <FadeIn/> supporting react-dom, react-native #1109

Open manudeli opened 4 months ago

manudeli commented 4 months ago

Package Scope

etc

Description

const PostsPage = () => {
  usePrefetchQuery(postsQueryOptions())

  const averageLoadingTimeQuery = useQuery({
    queryKey: ['averageLoadingTime'],
    queryFn: api.averageLoadingTime,
    placeholderData: 200, // If don't know the average API loading time yet, treat 200ms as the default value.
  })

  return (
    <Suspense
      fallback={
        // After delaying loadingTimeQuery.data, skeleton FadeIn for 300ms
        <FadeIn delay={loadingTimeQuery.data} ms={300}>
          <PostListSkeleton />
        </FadeIn>
      }
    >
      <SuspenseQuery {...postsQueryOptions()}>
        {({ data: posts }) => posts.map((post) => <Post key={post.id} {...post} />)}
      </SuspenseQuery>
    </Suspense>
  )
}

Possible Solution

No response

etc.

No response

manudeli commented 2 months ago

This is next plan

coauthors[bot] commented 2 months ago

People can be co-author:

Candidate Reasons Count Add this as commit message
@manudeli https://github.com/toss/suspensive/issues/1109#issuecomment-2333632913 https://github.com/toss/suspensive/issues/1109 2 Co-authored-by: manudeli <61593290+manudeli@users.noreply.github.com>