Page not loading after redirect
Unanswered
American posted this in #help-forum
AmericanOP
Hello!
I have a create page and an edit page. In my provider I have something like this:
My problem is that after doing
I'm on
I have a create page and an edit page. In my provider I have something like this:
const res = context.task
? await updateTask({
taskId: context.task.id,
data: object,
})
: await createTask(object);
if (res.data.type === "create") {
router.push(`/edit/${res.data.taskId}`);
router.refresh();
}
// more stuffMy problem is that after doing
router.push my edit/[id]/page.tsx isn't "called". I added a console log to the edit page but it's never printed. How can I force it to happen?I'm on
14.2.163 Replies
@American Hello!
I have a create page and an edit page. In my provider I have something like this:
ts
const res = context.task
? await updateTask({
taskId: context.task.id,
data: object,
})
: await createTask(object);
if (res.data.type === "create") {
router.push(`/edit/${res.data.taskId}`);
router.refresh();
}
// more stuff
My problem is that after doing `router.push` my `edit/[id]/page.tsx` isn't "called". I added a console log to the edit page but it's never printed. How can I force it to happen?
I'm on `14.2.16`
router.push();
router.refresh();looks funky -
router.push() should be enough and altough router.push and redirect is a different api they should result the samejust make sure you are using
redirect inside a server action or route handlerAmericanOP
Thanks for the reply James. Seems server redirect actually works fine, my e2e tests were just not handling the loading 🙄 the client side I couldn't get working, with or without refresh