I found the right answer for react on the API documentation https://docs.amplify.aws/react/start/quickstart/
import { useAuthenticator } from "@aws-amplify/ui-react";
const { signOut } = useAuthenticator();
I use signOut to log out
Log out