Permalink
Browse files

Updated to release version of react router v4

  • Loading branch information...
brookslyrette committed Mar 19, 2017
1 parent 07583c1 commit 12c03798710b2e47eeb24a4b743d5cf5e7d2a86a
@@ -14,7 +14,8 @@
"react-lazy-load": "^3.0.10",
"react-markdown": "^2.4.2",
"react-redux": "^4.4.5",
"react-router": "^4.0.0-alpha.4",
"react-router": "^4.0.0",
"react-router-dom": "^4.0.0",
"react-timeago": "^3.1.3",
"react-youtube": "^7.2.0",
"redux": "^3.6.0",
@@ -1,8 +1,7 @@
import React from 'react';
import { Link } from 'react-router'
import logo from './logo.svg';
import './App.css';
import { BrowserRouter, Match } from 'react-router';
import { BrowserRouter, Route, Link } from 'react-router-dom';

import FrontPageContainer from './containers/FrontPageContainer.js';
import SubredditPageContainer from './containers/SubredditPageContainer.js';
@@ -19,8 +18,8 @@ const App = (props) => (
<img src={logo} className="App-logo" alt="logo" />
<strong>Reactit!</strong> An Example ReactJs Reddit front-end
</div>
<Match exactly pattern="/" component={FrontPageContainer}/>
<Match exactly pattern="/r/:name" component={SubredditPageContainer} />
<Route exact path="/" component={FrontPageContainer}/>
<Route path="/r/:name" component={SubredditPageContainer} />
</div>
</BrowserRouter>
);
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router'
import { Link } from 'react-router-dom'

const DefaultReddits = (props) => (
<Link to={`/r/${props.reddit.display_name}`}>{props.reddit.display_name}</Link>
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router'
import { Link } from 'react-router-dom'

import ListingItem from './ListingItem.js';
import ListingType from './ListingType.js';
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router';
import { Link } from 'react-router-dom';
import ReactMarkdown from 'react-markdown';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import LazyLoad from 'react-lazy-load';
@@ -9,32 +9,33 @@ export class SubredditPageContainer extends Component {

constructor(props) {
super(props);
console.log(props)
this.changeType = (type) => this._changeType(type);
this.loadMore = () => this._loadMore();
}

componentWillMount() {
this.props.loadSubreddit(this.props.params.name, this.props.type);
this.props.loadSubreddit(this.props.match.params.name, this.props.type);
}

componentWillReceiveProps(nextProps) {
if (this.props.params.name !== nextProps.params.name) {
this.props.loadSubreddit(nextProps.params.name, this.props.type);
if (this.props.match.params.name !== nextProps.match.params.name) {
this.props.loadSubreddit(nextProps.match.params.name, this.props.type);
}
}

_changeType(type) {
this.props.changeListingType(type);
this.props.loadSubreddit(this.props.params.name, type);
this.props.loadSubreddit(this.props.match.params.name, type);
}

_loadMore() {
this.props.loadMoreSubredditItems(this.props.params.name, this.props.type, this.props.after);
this.props.loadMoreSubredditItems(this.props.match.params.name, this.props.type, this.props.after);
}

render() {
return (
<Listing items={this.props.items} reddit={this.props.params.name}
<Listing items={this.props.items} reddit={this.props.match.params.name}
type={this.props.type} changeType={this.changeType}
loadMore={this.loadMore} expandItem={this.props.expandItem}
/>
@@ -49,7 +50,7 @@ SubredditPageContainer.defaultProps = {
};

const mapStateToProps = (state, ownProps) => {
if (state.reddit === ownProps.params.name) {
if (state.reddit === ownProps.match.params.name) {
return {
items: state.items,
reddit: state.reddit,

0 comments on commit 12c0379

Please sign in to comment.