Skip to content

Commit

Permalink
feat: refresh rsc after mutation (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 authored Feb 19, 2024
1 parent 558512b commit d272e05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app/(account)/join/steps/StepFour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function StepFour() {
},
onSuccess: () => {
router.push('/settings');
router.refresh();
},
});

Expand Down
3 changes: 3 additions & 0 deletions src/app/(account)/join/steps/StepOne.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ControlledField from '@/components/ControlledField';
import { useSignUp } from '@clerk/nextjs';
import { zodResolver } from '@hookform/resolvers/zod';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { FcGoogle } from 'react-icons/fc';
Expand Down Expand Up @@ -33,6 +34,7 @@ function VerifyEmail() {

const [verifyEmailLoading, setVerifyEmailLoading] = useState(false);

const router = useRouter();
const handleVerify = form.handleSubmit(async ({ code }) => {
if (!isLoaded) return;

Expand All @@ -48,6 +50,7 @@ function VerifyEmail() {
return;
}
await setActive({ session: completeSignUp.createdSessionId });
router.refresh();
} catch (error) {
handleClerkErrors(error, form, [
{ code: 'form_param_nil', field: 'code', message: 'Please enter the the code.' },
Expand Down
5 changes: 4 additions & 1 deletion src/app/(account)/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FancyRectangle from '@/components/FancyRectangle';
import { useSignIn } from '@clerk/clerk-react';
import { zodResolver } from '@hookform/resolvers/zod';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { FcGoogle } from 'react-icons/fc';
Expand All @@ -28,6 +29,7 @@ export default function SignInPage() {

const [signInLoading, setSignInLoading] = useState(false);

const router = useRouter();
const handleSignIn = form.handleSubmit(async ({ email, password }) => {
if (!isLoaded) return;

Expand All @@ -41,7 +43,8 @@ export default function SignInPage() {

if (result.status === 'complete') {
await setActive({ session: result.createdSessionId });
location.href = '/';
router.push('/');
router.refresh();
} else {
console.log(result);
}
Expand Down

0 comments on commit d272e05

Please sign in to comment.