Webpage navigation is something that is intrinsic to almost every website that goes past “Hello World.” In this blog, I will be exploring React-Router, a client and server-side routing library that can run anywhere React can. More specifically, I will be focusing on what changed with the new v6 version…
React, The Extras.
We’ve all seen and read the React tutorials. We know about classes and components and JSX and whatnot, but then there comes the time when you have to start doing things for real. “Real” you say? Yes. Like connecting to a database or navigating around something larger than “Hello World.” Oh, then there’s that dreaded state thing. Well, let’s have a quick talk about the “Extras” that we can add into a React application.
In this blog, we will address adding routing using the React Router, adding data access using the JavaScript Fetch API, and creating a global state management feature using React’s built-in Context API.
One Router to Rule Them All: React Router
Previously, we looked at a very basic example of how one can benefit greatly by using community projects such as Formik to avoid the tedium of certain solutions while embracing convention to create composable and scalable applications. We will be build on that foundation to explore the objectively great library that is React Router.
React Router has been at the forefront of routing in the React ecosystem for as long as I can remember. If you’re new to React, this is the way to go when you move state and start needing more options such as parameterized routing, nesting, and conditional rendering. If you have experience with React, this brings a powerful pattern to bear in that everything is a component. It takes the composablity of React and uses that to its benefit, handling any and all use-cases with relative ease.
In this blog, we’ll introduce the basics of the React Router through hands-on examples using its features.