#```tsx
1 messages · Page 1 of 1 (latest)
import React from 'react';
export default async function RootLayout({
children,
}: {
children: React.ReactNode,
}) {
let props = <JSON Object>
return (
<html>
<body>
<Navbar />
{React.cloneElement(children, {props: props})}
</NextAuthProvider>
</body>
</html>
)
}
i dont think you have to say props
but uh
that may not be the issue
im also unsure if u can use cloning in a server component
No overload matches this call.
The last overload gave the following error.
Argument of type 'ReactNode' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor<any>>'
This is the full error ^
Nice! That did it!
Now to google how to get the prop haha
you get the prop just like normally in any component
Hm, my component is unhappy with that. I'll keep digging at it, I don't want to take all of your time!
Okay, I gotta ask...
export default async function Home(props) {
console.log("session", props)
return (
...
);
}
Here, the console logs
props { params: {}, searchParams: {} }
Any idea why it's doing this?
This is a server component as well
@rich grove
Sorry for the ping, it looks like Discord doesn't notify thread members of new messages
If it does then I'm extra sorry, I'm new to Discord
any idea its doing what?
It's returning a weird props { params: {}, searchParams: {} } object instead of the JSON object I'm sending it via the clone
Yes
oh
i should of noticed
this was a rootlayout
I don't think its possible for what ur trying to achieve
i think..
if it was just an array of components
thats one thing
but this is a array of components returned by a page.tsx
Oh, I think I see what you mean
Shoot, can you think of any other solutions to getting the data from the layout to here?
the only other way
is not really passing props
but its a clientside way using context
Damn, I was trying to avoid that because it causes weird re-rendering issues
Regardless, thanks for your help. You're awesome
alright but again
this is a hacky way of doing things
and i suspect this logic may breakdown if u have a dynamic route ur trying to pass props to children in
Luckily, I'm not. I kind of got it to work. I'll send another update once it's fully implemented.
ok
No luck man. I was able to get it to send params once but then after that it just decided it didn't want to work anymore. Their docs say it's impossible by design, which is frustrating.
Right, I've been considering using redux for state management but it's a beast to implement just for this.