FindFurryFriend — React Router

--

Photo by Radowan Nakif Rehan on Unsplash

Installation

npm install react-router-dom

Getting Started

Firstly, I imported BrowerRouter (and named it Router) and wrapped my whole app in it so it has access to router.

Index.js file (just showing the new edits):

Next, I created a separate Router.js file to put my routing in and imported the appropriate containers. I also imported switch from react-router in order to be able to switch between routes.

Router.js file:

Then, I went to my App file and imported the Router component (instead of having the pets container and shelter container listed).

App.js file:

And now we’re routing between components! Next i’m going to work on my home page and maybe make links to either the shelter page or the pets page.

References

React Router

--

--

No responses yet