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 ...
Get Programming Elm now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.