Using React Router 4: Lesson 8 of 12

Using Switch

Up Next

Blocking Transitions

Autoplaying in 7 seconds!

Cancel

Using Switch

Let's add a page to add a user. This should be pretty easy, right? Inside src/fe/components/Cms/index.js, let's add a new route that will render our UserAdd component when the URL matches /users/new.

import UserAdd from '../UserAdd';

...

<Route path="/users" component={Users} />
<Route path="/users/new" component={UserAdd} />

We have simply added a route under the route we already had in there. Load up the application in the browser and visit /users/new.

Well...ummm...WAT? Why is the users table still showing in the background? And why is the modal up? We can see the user add form under the modal too. It displayed them all!

Table of Contents

    Alex Sears

    2 posts

    Developing is not only my job but also my passion. I love to teach myself new things as much as I love teaching others. The more people we get involved in this little thing we call "web development," the better we can make it. I mean, we always need more cat videos, right?