Skip to content

Commit ca657fa

Browse files
committedDec 6, 2024
update
1 parent 6b98ede commit ca657fa

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed
 

‎app/signin/page.tsx

+21-11
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@ import { signIn } from 'next-auth/react';
44
import Image from 'next/image';
55
import Link from 'next/link';
66
import { useSearchParams } from 'next/navigation';
7-
import { FormEvent, useState } from 'react';
7+
import { FormEvent, Suspense, useEffect, useState } from 'react';
88
import { toast } from 'react-toastify';
99

10-
export default function Signin() {
11-
const [email, setEmail] = useState('');
12-
const [password, setPassword] = useState('');
10+
function OAuthError() {
1311
const params = useSearchParams();
1412

15-
const error = params.get('error');
16-
if (error) {
17-
if (error === 'OAuthAccountNotLinked') {
18-
toast.error('Unable to signin. The user email may be already in use.');
19-
} else {
20-
toast.error(`Authentication error: ${error.toString()}`);
13+
useEffect(() => {
14+
const error = params.get('error');
15+
if (error) {
16+
if (error === 'OAuthAccountNotLinked') {
17+
toast.error('Unable to signin. The user email may be already in use.');
18+
} else {
19+
toast.error(`Authentication error: ${error.toString()}`);
20+
}
2121
}
22-
}
22+
}, [params]);
23+
return null;
24+
}
25+
26+
export default function Signin() {
27+
const [email, setEmail] = useState('');
28+
const [password, setPassword] = useState('');
2329

2430
async function onSignin(e: FormEvent<HTMLFormElement>) {
2531
e.preventDefault();
@@ -115,6 +121,10 @@ export default function Signin() {
115121
</form>
116122
</div>
117123
</div>
124+
<Suspense>
125+
{/* Suspense is needed because 🤔: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout */}
126+
<OAuthError />
127+
</Suspense>
118128
</div>
119129
);
120130
}

‎next.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
const nextConfig = {
33
reactStrictMode: true,
44
images: {
5-
domains: ['picsum.photos', 'lh3.googleusercontent.com', 'avatars.githubusercontent.com'],
5+
remotePatterns: [
6+
{ hostname: 'picsum.photos' },
7+
{ hostname: 'lh3.googleusercontent.com' },
8+
{ hostname: 'avatars.githubusercontent.com' },
9+
],
610
},
711
};
812

0 commit comments

Comments
 (0)
Failed to load comments.