Intercepting / Parallel route w/modal causing application error
Answered
American Wirehair posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
I am creating a user modal to intercept the user route on my project, but it appears to be causing an Application Error for which i am utterly confused.
Project structure
Layout contains the slot
Default returns
Contains the shadcn/ui
The general problem
Navigating from
Project structure
├ app
│ ├── (site)
│ │ ├── @modal
│ │ │ ├── (.)user
│ │ │ │ ├── [id]
│ │ │ │ │ ├── page.tsx
│ │ │ │ ├── default.tsx
│ ├── user
│ │ ├── [id]
│ │ │ ├── page.tsx
│ ├── users
│ │ ├── page.tsx
│ ├── layout.tsx
│ ├── page.tsx
layout.tsx
Layout contains the slot
{props.modal}
inside the <body>
tag.default.tsx
Default returns
null
.@modal/(.)user/[id]/page.tsx
Contains the shadcn/ui
<Dialog open>
with some hardcoded text.The general problem
Navigating from
/users
to /user/id
causes an Application Error at which point the URL is still /users
, hitting the back button updates URL to /user/123..
where if a refresh the application it shows the user page. Is this something to do Route Groups?Answered by Ray
try moving
app/(site)/@modal/(.)user/default.tsx
to app/(site)/@modal/default.tsx
22 Replies
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
try create a
layout.tsx
inside app/(site)
and render the modal props in it![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
Hey @Ray thanks for the reply, my layout.tsx is rendering the slot as a prop...
export default function DefaultLayout(props: {
children: React.ReactNode;
modal: React.ReactNode;
}) {
return (
<html lang="en">
<ThemeProvider>
<body className="...">
<NextAuthProvider>
<Header />
{props.children}
{props.modal}
<Toaster position="top-center" />
</NextAuthProvider>
</body>
</ThemeProvider>
</html>
);
}
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
is this
app/layout.tsx
?![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
this is
(site)/layout.tsx
which is the top level since i have app/api
and app/(site)
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
oh ok let me see
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
try moving
app/(site)/@modal/(.)user/default.tsx
to app/(site)/@modal/default.tsx
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
no joy, didnt work 😦
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
what error do you get?
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
Browser
Console
Application error: a client-side exception has occurred (see the browser console for more information).
Console
Uncaught TypeError: initialTree is not iterable
at ...
``![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
goto /users > /users/[id] and the error appear?
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
brooooo
i just deleted
.next
dir and it worksthat's with default.tsx in the
@modal/
dir![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
yea
I cloned your repo and got 404
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
fml
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
after I moved the default.tsx and it work
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
nice man, thank you for working it through with me!
Messi GOAT
Messi GOAT
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
you're welcome
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
American WirehairOP
Thanks again mate
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Masai Lion
worked for me. but i dont know why!