title: React throwing TypeError: undefined is not an object (evaluating 'view.states')
body: <pre><code>import React, { Component } from 'react';
  import ReactDOM from 'react-dom';
  
  class App extends Component {
  
    constructor(props){
      super(props);
      this.state={
      countryVal:''
      };
  
      this.handleChange3 = this.handleChange3.bind(this);
    };
  
     handleChange3(event){
      this.setState({countryVal:event.target.value});
  
    }
  
        render() {
  
        const {countryVal} = this.state
        const VIEWS = [
        {
          country: 'India', 
          states: ['Kerala', 'Karnataka','Tamil nadu'] 
        }, {
          country: 'America', 
          states: ['test1', 'test2', 'test3']
        }, {
          country: 'Africa', 
          states: ['test4', 'test5', 'test6']
        }
      ]
  
      const getMajorMethod = () =&gt; {
          const view = VIEWS.filter(({country}) =&gt; country === countryVal )[0]
          return(
              &lt;select id="stateSelectId"  style={{'width':'150px','display':'block'}}&gt;
                  {view.states.map(m =&gt; &lt;option&gt;{m}&lt;/option&gt;)}
              &lt;/select&gt;
  
          )
      }     
  
        return (
        &lt;div&gt;
          &lt;div style={{'border':'1px solid gray','padding':'20px','margin':'20px'}}&gt;
              &lt;select  onChange={this.handleChange3} style={{'width':'150px'}}&gt;
                  {VIEWS.map(({country}) =&gt; &lt;option value={country}&gt;{country}&lt;/option&gt;)}
              &lt;/select&gt;
              &lt;br/&gt;&lt;br/&gt;
              {getMajorMethod()}
          &lt;/div&gt;
  
  
       &lt;/div&gt; 
      );
    }
  }
  
  export default App;
  </code></pre>
  
  <p>I'am trying to implement react app where state dropdown gets changes on selecting country dropdown.</p>
  
  <p>but i'am facing issue in loading states to select menu.
  its throwing "React throwing TypeError: undefined is not an object (evaluating 'view.states')"</p>
  
  <p>on removing the "{getMajorMethod()}" its is displaying country without any error.</p>
  
  <p>I'am a beginner in react.
  have looked many similar answers but not getting any solutions for this.</p>
  
  <p>above is the code in APP.js</p>
  
  <p>I referred the answer in
  <a href="https://stackoverflow.com/questions/49239766/populate-two-dropdown-based-on-selection-in-another-1-in-react">Populate two dropdown based on selection in another 1 in react</a></p>