I am trying to handly a basic AppBar (using MUI) and i need to know if the user is logged in or not.
This AppBar is part of the RootLayout (and it seems to be the whole problem).
I can’t find a “built-in” way to get the current user from the RootLayout, and i didn’t find this use case from the document (from a page yes but not from the layout).
I am using next v14 and aws-amplify v6 by the way
I tried this very simple code example (this AppBar is not there bu the problem already appears with only that
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import { Authenticator } from "@aws-amplify/ui-react";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "test title",
description: "test descrition",
};
function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={inter.className}>
<Authenticator>
{children}
</Authenticator>
</body>
</html>
);
}
export default RootLayout;
I get this error:
⨯ ./node_modules/@aws-amplify/ui-react-core/dist/esm/components/FormCore/FormProvider.mjs Attempted import error: 'useForm' is not exported from 'react-hook-form' (imported as 'useForm').
If i remove the wrapper, the error goes away