0
0
Remixframework~20 mins

Dynamic route parameters in Remix - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dynamic Route Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What does this Remix route component render?
Given a dynamic route file named routes/posts/$postId.jsx in Remix, what will the component render if the URL is /posts/42?
Remix
import { useParams } from '@remix-run/react';

export default function Post() {
  const params = useParams();
  return <div>Post ID is {params.postId}</div>;
}
APost ID is $postId
BPost ID is 42
CPost ID is undefined
DError: useParams is not a function
Attempts:
2 left
💡 Hint
Remember that dynamic route parameters are available via useParams hook.
📝 Syntax
intermediate
1:30remaining
Which route file name correctly defines a dynamic parameter for user ID?
In Remix, which file name correctly creates a route with a dynamic parameter named userId?
Aroutes/users/:userId.jsx
Broutes/users/[userId].jsx
Croutes/users/$userId.jsx
Droutes/users/userId.jsx
Attempts:
2 left
💡 Hint
Remix uses a special prefix for dynamic segments in file names.
state_output
advanced
2:30remaining
What is the value of params in nested dynamic routes?
Consider the nested route files routes/blog/$category/$postId.jsx. If the URL is /blog/tech/123, what is the value of params from useParams() inside the component?
Remix
import { useParams } from '@remix-run/react';

export default function Post() {
  const params = useParams();
  return <div>{JSON.stringify(params)}</div>;
}
A{"category":"tech","postId":"123"}
B{"category":"blog","postId":"tech"}
C{"postId":"123"}
D{}
Attempts:
2 left
💡 Hint
All dynamic segments in the route path are included in params.
🔧 Debug
advanced
2:30remaining
Why does this dynamic route component fail to get the parameter?
Given the route file routes/products/$productId.jsx and this component code, why does params.productId return undefined?
Remix
import { useParams } from '@remix-run/react';

export default function Product() {
  const params = useParams;
  return <div>Product: {params.productId}</div>;
}
AThe dynamic segment should be named $productID with uppercase D.
BuseParams hook only works in server components, not client components.
CThe route file name must be $productId.tsx, not .jsx.
DuseParams is not called as a function, so params is the function itself, not the params object.
Attempts:
2 left
💡 Hint
Check how useParams is used in the code.
🧠 Conceptual
expert
3:00remaining
How does Remix handle optional dynamic route parameters?
Which statement correctly describes how Remix supports optional dynamic route parameters in file naming and routing?
ARemix does not support optional dynamic parameters directly; you must create separate routes for each case.
BYou can add a question mark after the parameter name in the file like $id?.jsx to make it optional.
COptional parameters are defined by prefixing the file name with an underscore like _$id.jsx.
DRemix supports optional parameters by wrapping the dynamic segment in parentheses like ( $id ).jsx.
Attempts:
2 left
💡 Hint
Think about how Remix routing matches files to URLs.