-
Notifications
You must be signed in to change notification settings - Fork 47.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: When I Use use() in server component, get [Error: Expected a suspended thenable. This is a bug in React. Please file an issue.] #32483
Comments
Fixing "Expected a Suspended Thenable" Error in React Server ComponentsCause of the IssueThe error "Expected a suspended thenable" occurs because the Why Does This Happen?
Solution: Remove
|
Your code has several issues which are misusing React, and likely putting it in an unexpected state which causes the error.
Putting these fixes together, I think you should update your code to the following: // in page.tsx
import { getItsmeStores } from '@/actions/itsme-v1/store/action'
import ItsmeStoreRadio from '@/components/store-radio/itsme-store-radio'
import React, { Suspense } from 'react'
import { getItsmeProductCategories } from '@/actions/itsme-v1/store/category/action'
import StoreProductCategoriesContent from '@/app/(main)/store/product-categories/_components/content'
type StoreProductCategoriesPageProps = {
searchParams: { [key: string]: string | undefined }
}
const StoreProductCategoriesPage = async (
props: StoreProductCategoriesPageProps,
) => {
const { searchParams } = props
const storeID = searchParams?.store_id ?? ''
const stores = await getItsmeStores()
const initialCategories = await getItsmeProductCategories(storeID)
return (
<>
<ItsmeStoreRadio stores={stores} />
<StoreProductCategoriesContent
storeID={storeID as string}
initialCategories={initialCategories}
/>
</>
)
}
export default StoreProductCategoriesPage // in loading.tsx
import Loading from '@/app/(main)/store/product-categories/loading'
export default LoadingFallback() {
return <Loading />
} |
React version: 19.0.0
Steps To Reproduce
use()
and avoid usinguseEffect()
in client component for performanceLink to code example:
The current behavior
so I tried to getting static storeID instead of getting searchParams by props.
But, it didn`t work.. :(
The expected behavior
But, I found the reason...!
Remove
async()
is the answer.And if you don't mind, I would appreciate it if you could explain in detail the cause of this issue.
thank you.
vercel/next.js#51477
The text was updated successfully, but these errors were encountered: