title: React - how to set initial state from URL parameters with React Router V4
body: <p>I am passing an ID in URL like so:</p>
  
  <pre><code>&lt;Link title="Open goal" to={"/app/goal/id"+key}&gt;Open goal&lt;/Link&gt;
  </code></pre>
  
  <p><strong>And the route is working perfect</strong> (<em>/app/goal/id-Kho8lGjYN31WiYwgthE</em>):</p>
  
  <pre><code>&lt;Route path="/app/goal/id:goalId" component={GoalView} /&gt;
  </code></pre>
  
  <p>I just want to get the <code>goalId</code> from the URL in a component class constructor to set it as a state. I just don't know what is thy right syntax to do so.</p>
  
  <p><strong>I was trying something like:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class GoalView extends Component {
    constructor(props) {
      super(props);
  
      this.state = {
        dataGoal: {},
        currentGoalId: this.props.match.params.goalId,
      };
    }
    
    ...
    
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>but that doesn't work ending in a <code>ReferenceError: match is not defined</code>.</p>
  
  <p>Any ideas how can I get the <code>goalId</code> from the URL?</p>
  
  <p>Thanks for any help,
  Jakub</p>
  
  <blockquote>
    <p>I am so sorry... I have figured it out. I had an error on a totally
    different row. It is working just fine.</p>
  </blockquote>