Please refer to the following discussion.
https://github.com/nextauthjs/next-auth/discussions/11271
In my case, modifying the import as follows solved the problem:
import { signOut } from "next-auth/react";
It seems to be working properly, but I'm very confused. I can't understand why it has to be done this way.