我正在尝试制作一个登录页面。在我的 page.tsx 文件上,我收到两个错误之一,具体取决于我是否包含“使用客户端”;在我的代码的顶部。如果我没有“使用客户端”;我收到此错误:
Error: React Context is unavailable in Server Components
如果我确实使用“使用客户端”;我收到此错误:
Error: [next-auth]: useSession must be wrapped in a <SessionProvider />
这是我的layout.tsx 文件:
import Image from 'next/image'
import { SessionProvider } from "next-auth/react";
import { ReactNode } from "react";
import React from 'react';
import "./globals.css";
import Link from "next/link";
type Props = {
children: ReactNode;
session: any;
};
export default function Layout({ children, session }: Props) {
return (
<html lang="en">
<head />
<body>
<div className="mx-auto">
<div className="flex flex-row …Run Code Online (Sandbox Code Playgroud)