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!
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

Sam Bartlett
5,886 PointsWhy does match get passed in as {match} compared to, for example, props which just gets passed in as props?
Ex. usually we do:
const SampleComponent = props => {};
but for match properties we have to do:
const SampleComponent = {match} => {};
Why?
1 Answer

Ari Misha
19,323 PointsHiya there! In React, the data flow is unidirectional. The children functions(components) is unaware of state or data that their parent components possess. So how do you make 'em aware? Props comes to the rescue. the props is pretty much whatever the data you pass to the parent component, which later flows down to children components. Thats how it works in React.
Now match is something totally different than props. A "match" object contains information about how a <Route path> matched the URL. * **matchobject contains properties like *params, isExact, path and url. match object works for server-side rendering.
~ Ari

Sam Bartlett
5,886 PointsHiya Ari, thanks for the answer! Unfortunately, it doesn't really answer what I'm trying to understand.
There's a syntax difference here. With props
we pass the props object as a normal variable - in more traditional js:
var component = function(props) { console.log(props) }
But match
is different:
var component = function({match}) { console.log(match) }
I don't understand this syntax. In other places in react, we use {} to indicate an expression. But match is already a javascript object, why does it need to be passed as an expression? Is that actually what's happening here?

Ari Misha
19,323 PointsHiya there! Maybe i misunderstood the question. {match}
is newer syntax in JavaScript called destructuring. It pretty much means that you're calling the match object, which is an object in React Library. I think you're confused with this ES6 syntax. Post back if you still cant grasp the concept. (:

Sam Bartlett
5,886 PointsAri Misha thanks, that's exactly what I was trying to understand. I'm not familiar with the new destructuring concept. Are there any treehouse courses etc. that would cover this topic?

Sam Bartlett
5,886 PointsAwesome, thank you for the links. I'll work on that track after I finish the react track then, I really appreciate you taking the time to answer me!

Ari Misha
19,323 PointsI would finish it right now if i were you 'coz its gonna be a lot harder without learning new ES6 syntax. The whole React library is written in ES6 syntax and future courses will be in ES6 syntax as well. So you're gonna encounter ES6 syntax one way or another.
Sam Bartlett
5,886 PointsSam Bartlett
5,886 PointsThis is for React using React Router.