Next.js Discord

Discord Forum

nextjs error

Unanswered
Peterbald posted this in #help-forum
Open in Discord
Avatar
PeterbaldOP
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of LoginPage.

Anyone know how to fix this error? (will provide code if it isnt an obvious fix)

1 Reply

Avatar
PeterbaldOP
import { useSession, signIn, signOut } from "next-auth/react"
import { LoginBtn } from "./components/LoginBtn.jsx"

export default function LoginPage() {
  const { data: session, status } = <useSession />
  const userEmail = session?.user?.email

  if (status === "loading") {
    return <p>Hang on there...</p>
  }

  if (status === "authenticated") {
    return (
      <>
        <p>Signed in as {userEmail}</p>
        <button onClick={() => signOut()}>Sign out</button>
        <img src="https://cdn.pixabay.com/photo/2017/08/11/19/36/vw-2632486_1280.png" />
      </>
    )
  }

  return (
    <>
      <p>Not signed in.</p>
      <LoginBtn />
    </>
  )
}