Using Hooks for Routing
In the previous chapter, we learned how to use Hooks for handling form submission using the Action State Hook, how to avoid blocking UI with the Transition Hook, and how to use the Optimistic Hook to implement optimistic updates.
In this chapter, we are going to learn how to implement client-side routing in our blog app by using React Router. First, we will learn how React Router works, and which features it offers. Then, we will be creating a new route for viewing a single post and using the Param Hook to get the post ID from the URL. Next, we will learn how to use the Link
component to link to different routes. Finally, we will learn how to programmatically implement navigation to redirect to a newly created post using the Navigation Hook.
The following topics will be covered in this chapter:
- Introducing React Router
- Creating a new route and using the Param Hook
- Linking to routes using the Link component
- Programmatically...