Thus far, the extent of my knowledge about how properties are passed from one component to another via parameters is as follows
//start: extent of my knowledge
Suppose there exists some state variable called topic
in A.jsx.
I want to pass this down to B.jsx, so I perform the following
B = require('./B.jsx')
getInitialState: function() {return {topic: "Weather"}}
<B params = {this.state.topic}>
In B.jsx I can then do stuff like
module.exports = React.createClass({
render: function() {
return <div><h2>Today's topic is {this.props.params}!</h2></div>
}
})
which when called upon will render "Today's topic is Weather!"
//end: extent of my knowledge
Now, I'm going through a tutorial on react-router with the following code snippets
topic.jsx:
module.exports = React.createClass({
render: function() {
return <div><h2>I am a topic with ID {this.props.params.id}</h2></div>
}
})
routes.jsx:
var Topic = require('./components/topic');
module.exports = (
<Router history={new HashHistory}>
<Route path="/" component={Main}>
<Route path = "topics/:id" component={Topic}></Route>
</Route>
</Router>
)
header.jsx:
renderTopics: function() {
return this.state.topics.map(function(topic) {
return <li key = {topic.id} onClick={this.handleItemClick}>
<Link to={"topics/" + topic.id}>{topic.name}</Link>
</li>
})
}
where this.state.topics
is a list of topics drawn from the imgur API via Reflux.
My question is: by what mechanism is params
passed in to props
for topic.jsx? Nowhere in the code do I see an idiom as expressed in the above section on the "extent of my knowledge" viz. there is no <Topic params = {this.state.topics} />
in either routes.jsx or header.jsx. Link to the full repo here. React-router docs says that params is "parsed out of the original URL's pathname". This did not resonate with me.