Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Router 4 Basics Getting Started with React Router Installing React Router and Declaring Routes

Mia Filisch
Mia Filisch
16,117 Points

Course content outdated: Recommended Syntax for declaring routes

The Treehouse React Router course introduces two ways of rendering components in routes in this and the following video:

  • Using the component prop:
<Route exact path="/" component={Home} />
  • Using the render prop:
<Route path="/about" render={() => <About title="About" />} />

However, all the examples of Route in the React Router docs instead use a different, newer syntax which renders the component as a child of Route, the two examples above would then look like this:

<Route exact path="/">
    <Home />
</Route>
<Route path="/about" >
    <About title="About" />
</Route>

Section of the docs about this being the recommended approach: https://reactrouter.com/web/api/Route/route-render-methods

It would be great if the course could be updated to reflect this.

Thanks a lot for this.

Mia Filisch
Mia Filisch
16,117 Points

Eduardo Osorio - you can still access the match object, one way of accessing it is via the useRouteMatch() hook. Example usage:

import React from 'react';
import { useRouteMatch } from 'react-router-dom';

const Featured = () => {
  let match = useRouteMatch();
  let name = `${match.params.fname} ${match.params.lname}`;
  let topic = match.params.topic;

  return (
    <div className="main-content">
      <h2>{name}</h2>
      <p>Introducing <strong>{name}</strong>, a teacher who loves teaching courses about <strong>{topic}</strong>!</p>
    </div>
  );
}

export default Featured;

It's been a while since I took the course so if this doesn't solve your issue pls do share more details on where you're getting stuck and I can try and refresh my memory to help more :)

Docs: https://reactrouter.com/web/api/Hooks/useroutematch

4 Answers

I share your thoughts. It is quite annoying to be paying so much for lessons that are outdated by almost 4 years. I really wonder if Treehouse ever intends on updating any of their content. Seems like they want to just fall back on their Slack Team and students to address issues with their content.

Mark Westerweel
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mark Westerweel
Full Stack JavaScript Techdegree Graduate 22,378 Points

Yeah, wondered about that as well. I think a lot drop out, since I see very few graduates on here (you should be able to stay on to peer review, imho -- I mean, it HELPS them as well (a lot) ). Or be able to do tracks if you help out or something.

I will finish the course and continue on Pluralsight, etc, along with opting for a bootcamp. Treehouse is good for a foundation, but that's it. Bit expensive when you indeed take in consideration that lot of it is outdated.

Not expecting this platform to be around in another 4 year, TBH

It's frustrating paying so much for a program which doesn't keep their content current and has broken videos all over the place. I'm sure other students also expect to be taught current material inline with the latest versions of the languages and packages we are learning. I started seeing this downhill pattern as we started getting into React. It seems to be going further down hill. Will keep trying to stay engaged to see if it gets any better.

Mark Westerweel
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mark Westerweel
Full Stack JavaScript Techdegree Graduate 22,378 Points

Seriously, I am a bit further.

Save your money. Do code academy, odin project for free.

Money vakue is Wes Bos or JOSH COMEAU (when he accepts again) and just build on your own.

Most here is from docs anyways and nowadays you really don't want class components and separate css files, lol.

DM me on twitter @I_Am_Coding

Mark Westerweel
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Mark Westerweel
Full Stack JavaScript Techdegree Graduate 22,378 Points

Seriously, I am a bit further.

Save your money. Do code academy, odin project for free.

Money vakue is Wes Bos or JOSH COMEAU (when he accepts again) and just build on your own.

Most here is from docs anyways and nowadays you really don't want class components and separate css files, lol.

DM me on twitter @I_Am_Coding