Hey, so basically I have the following structure
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import Header from "@/components/Header";
import checkoutService from '@/services/checkout';
import { Checkout } from '@/types/Checkout';
const inter = Inter({ subsets: ['latin'] })
export const metadata: Metadata = {
title: 'Cotton Castle',
description: 'Need something to stand out at the next joust? Cotton Castle has you covered.',
}
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
async function createCheckout(checkout: Checkout) {
'use server';
return () => null;
}
return (
<html lang="en">
<head>
</head>
<body className={inter.className}>
<Header createCheckout={createCheckout}/>
{children}
</body>
</html>
)
}
Header.tsx
const Header: React.FC<HeaderProps> = ({createCheckout}) => {
const pathname = usePathname();
const isActive = (_pathname: string) => {
return pathname === _pathname;
}
useEffect(() => {
let resp = createCheckout({} as any);
}, []);
...
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
{: function}
^^^^^^^^