Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refresh rsc after mutation #94

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading