title: React Router v4 Multiple Dynamic Routes
body: <p>I'm new to React Router so if this has been asked before maybe someone could point me in the right direction! Basically I have a WordPress install that I'm pulling in my websites data from through the API.</p>
  
  <p>I've created custom routes to query my pages and my posts by slug. </p>
  
  <p>Using react router I was able to create a template called Page.js which changes dynamically using the code below.</p>
  
  <p>However, now I'm trying to do the same exact thing with the blog posts but the app isn't using Blog.js its still defaulting back to Page.js</p>
  
  <p>here's my App.js code...</p>
  
  <pre><code>import React from "react";
  import { BrowserRouter as Router, Route } from "react-router-dom";
  import Home from './pages/Home';
  import Page from './pages/Page';
  import Blog from './pages/Blog';
  import Header from './components/Header';
  import Footer from './components/Footer';
  
  class App extends React.Component {
    render() {
      return (
        &lt;Router&gt;
        &lt;div&gt;
            &lt;Header/&gt;
            &lt;Route exact path="/" component={Home} /&gt;
            &lt;Route path="/:slug" component={Page} /&gt;
            &lt;Route path="/blog/:slug" component={Blog} /&gt;
            &lt;Footer/&gt;
        &lt;/div&gt;
        &lt;/Router&gt;
      );
    }
  }
  
  export default App;
  </code></pre>
  
  <p>More Details: </p>
  
  <p>Page.js works by checking const { slug } = this.props.match.params; and then querying WordPress using that slug to pull in the data it needs. In componentDidUpdate i'm checking prevProps to see if the slug matches the previous slug, if not it fetching the new data.</p>
  
  <p>This works great and I was hoping to do the same in the Blog.js as well.</p>
  
  <p>However, if this isn't the best approach please advise another method. </p>