title: TypeError: Cannot read property 'toUpperCase' of undefined (React)
body: <p>I want to get the name of the page from <strong>props</strong> match, here's the attempt below on first boot</p>
  
  <p>The console does not display the call to this.props.match.path</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>import React, {Component} from 'react'
  import Post from './Post'
  
  export default class Posts extends Component {
      state = {
        namePage: ''
     };
     componentWillMount() {
      this.setState({
          namePage: this.props.match.path.slice(1)[0].toUpperCase() + this.props.match.path.slice(2)
      })
    render(){
      return (
               &lt;div&gt;
                     &lt;h2&gt;{this.state.namePage}&lt;/h2&gt;
               &lt;/div&gt;
  
      )
  }
  
  }</code></pre>
  </div>
  </div>
  
  <a href="https://i.stack.imgur.com/I58mf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I58mf.png" alt="введите сюда описание изображения"></a>
  that's what I get when starting the reaction, help me understand what I'm doing wrong</p>