Handle Dynamic Routes
Up to this point, you’ve used static URL paths such as / and /account that fetch static resources. Many SPAs also access dynamic resources through parameterized paths. For example, a path of /photo/42 would fetch and display the photo with an ID of 42.
In this section, you will learn how to handle dynamic paths. You will add the ability to view an individual user’s feed of photos. You will create a parameterized route for a user’s feed. Then, you will make wrapper components that reuse the Feed component to display the public feed and user feeds.
You will use usernames to fetch user feeds, so start by displaying the username associated with a photo. Open Feed.elm in your editor. Add a String username field below the comments ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access