Next.js Discord

Discord Forum

Same page, different query string value re-rendering, no skeleton

Unanswered
Japanese pilchard posted this in #help-forum
Open in Discord
Japanese pilchardOP
Attached is a video of the problem. u see going from one chapter to another (?chapter=1 goes to chapter=2 for example), it is the same page, but is fetching different data from the db, but in the same structure, so I guess it thinks it is still rendered so the skeleton doesn't fire again.

Any suggestions? Maybe moving from the /{course}?chapter=x to /{course}/{chapter} would be better, but the logic would be ideal to be encapsulated in one page but idk

(vid starts at 0:05)

12 Replies

Shy Albatross
moving from the /{course}?chapter=x to /{course}/{chapter}
+1
it can still be one page with a catch all route
@Shy Albatross it can still be one page with a catch all route
Japanese pilchardOP
i've never done a catch all inside a catch all
@Shy Albatross it can still be one page with a catch all route
Japanese pilchardOP
so the url rn is courses/{slug} which is the course name
@Shy Albatross it can still be one page with a catch all route
Japanese pilchardOP
and so I guess it would be as an example, courses/web-optimization/1 ?
Shy Albatross
courses/[slug]/ isn't a catch all, it's just a segment, a catch all would be courses/[...course]/ which would match both courses/foo as well as courses/foo/5 and you get those params in a nice list
do u figure if i don't have a courses/{slug} page, I should just have that page redirect to chapter-1 for example
Shy Albatross
or courses/[slug]/[[...chapter]] so an optional cat all segment maybe, depends on how you want to wire it
@Japanese pilchard do u figure if i don't have a courses/{slug} page, I should just have that page redirect to chapter-1 for example
Shy Albatross
hmm you can do that with error.js and return a redirect to chapter-1 there I guess
@Shy Albatross hmm you can do that with error.js and return a redirect to chapter-1 there I guess
Japanese pilchardOP
good idea thx