Reputation: 51
Am I doing something wrong? this.props.children doesn't get rendered when i go to this URL http://localhost:7000/#/about
--// file name: main.js
import React from 'react';
import { Router, Route, Link } from 'react-router';
import { history } from 'react-router/lib/BrowserHistory';
import Wrapper from "./components/Wrapper.react";
import ThumbnailContainer from './components/ThumbnailContainer.react';
React.render((
<Router history={history}>
<Route path="/" component={Wrapper}>
<Route path="/about" components={ThumbnailContainer}>
</Route>
</Route>
</Router>
), document.body);
--//file name:Wrapper.react.js
var Wrapper = React.createClass({
getInitialState: function() {
return(
{
className : "p-wrapper p-blue-theme"
}
);
},
render: function () {
return(
<div className={this.state.className} >
{this.props.children}
</div>
);
}
});
exports['default'] = Wrapper;
module.exports = exports['default'];
--// file name:ThumbnailContainer.react.js
var React = require('react');
var ThumbnailContainer = React.createClass({
render: function(){
return (
<div className="p-thumbnail-container">
<a className="p-thumbnail" href="#">
<div className="p-thumbnail-img-container">
<img src="http://placehold.it/200x200" className="p-thumbnail-img" />
</div>
<div className="p-thumbnail-caption">
<h3 className="p-title">Thumbnail Title</h3>
<h4 className="p-sub-title">Thumbnail Sub Title</h4>
<p className="p-description">Thumbnail Description Lorem Ipsum</p>
</div>
</a>
</div>
);
}
});
module.exports = ThumbnailContainer;
Upvotes: 1
Views: 228
Reputation: 637
Try removing the '/' from '/about'. The route is nested so I believe that the leading '/' after the '/' default route is redundant. Let us know if that works.
Upvotes: 0
Reputation: 1899
Change components={ThumbnailContainer} to component={ThumbnailContainer}.
Upvotes: 1