getting the error Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead. , i have the api fetch awaited and res.json() awaited, still getting this error. had the same code with vite and react-router and didnt get an error. any idea why this is?
#SOLVED React can't read serverSideProps object return
41 messages · Page 1 of 1 (latest)
Need more code but it sounds like you're returning a promise that resolves to the props, but not the props themselves
Yeah typeof getServerSideProps is incorrect
I'm guessing. I'm not exactly sure what the Infer generic is.
this should not cause the error you mentioned
can you show more code?
export const getServerSideProps = async (context: any) => {
let cookie: any
let data: stat_banner_user
if (context.req.cookies['osu_user']) {
cookie = context.req.cookies['osu_user']
console.log(cookie)
// const user = await handler(cookie)
const res = await fetch(`${base}/user/${cookie}`)
data = await res.json()
console.log(data)
}
else {
data = { osu_auth: false, osu_id: 0 }
}
return { props: {data} }
}
export default async function Home({ data }: InferGetServerSidePropsType<typeof getServerSideProps>) {
// use returned data in return ()
}
that error should be coming from your component
what you see if you console.log(data) in home ?
the fetched api data
should be something wrong with the component you are rendering
Cant you just provide the whole code not parts of it?
what does loadFull function return?
and particlesLoaded didn't return anything and you passing it to Particles component
particlesInit didn't return anything too
i just copied it from the react-tsparticles package page
how does Particles component look like?
ok
can you try comment out the Particles component to see if the error goes away
also you don't need html and body tag in the page component
still returns the same error
same erorr
that does it
yea
page component can't be an async function
unless you are using server component with app dir