useSession API
useSession Hook 的 API 参考。
导入
import useSession from '@toolpad/core/useSession';
// or
import { useSession } from '@toolpad/core';
阅读这篇关于最小化包大小的指南,了解它们之间的区别。
用法
通过调用 Hook,您可以访问 Toolpad Core 组件内部 SessionContext
的当前值
const session = useSession();
由 `@toolpad/core` 导出的默认 Session
接口包含以下字段
export interface Session {
user?: {
id?: string | null;
name?: string | null;
image?: string | null;
email?: string | null;
};
}