Abhinav kumar
Abhinav kumar

Reputation: 1

TypeError: Cannot read properties of null (reading 'name')

this is the image

import {getProviders, signIn} from "next-auth/react";

function Login(providers) {
  return (
    <div>
      <img className="w-52 mb-5" src="https://links.papareact.com/9xl" alt="" />

    {Object.values(providers).map((provider) => (
      <div>
        <button>Login with {provider.name}</button>
        console.log(provider.name);
      </div>
    ))}

    </div>
  );
}

export default Login;

export async function getServerSideProps() {
  const providers= await getProviders();

  return{
    props:{
      providers,
    },
  };
}

Upvotes: 0

Views: 75

Answers (1)

Poovarasan S
Poovarasan S

Reputation: 36

import {getProviders, signIn} from "next-auth/react";

function Login(providers) { return (

{Object.values(providers).map((provider) => (
  <div>
    <button>Login with {provider?.name}</button>
    console.log(provider?.name);
  </div>
))}

</div>

); }

export default Login;

export async function getServerSideProps() { const providers= await getProviders();

return{ props:{ providers, }, }; }

Upvotes: 0

Related Questions