title: react.js , JS: Getting access to nested object property through function parameter
body: <p>I am in progress of doing weather app , and i am calling API to send me back weather data so i am reciving back an JSON , it looks somehow like that:</p>
  
  <pre><code>{
   someprops: someval,
   .... ,
   list: [
     0: {
       main:{someprops},
       wind:{someprops},
       ...
     },
     1: {propsAsAbove},
      ...
     ]
   }
  </code></pre>
  
  <p>so , i have a table where in every row i have to do same map method on the list from api and it looks as beneath:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;hour &lt;/td&gt;
      {weatherInfo.list.map((item,idx) =&gt; {
          while(idx &lt; displayItemTo &amp;&amp; idx &gt;= displayItemFrom){
              return(
                  &lt;td&gt;{weatherInfo.list[idx].dt_txt.slice(11,19)}&lt;/td&gt;
              )
          }
      })}
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;temp&lt;/td&gt;
      {weatherInfo.list.map((item,idx) =&gt; {
          while(idx &lt; displayItemTo &amp;&amp; idx &gt;= displayItemFrom){
              return(
                  &lt;td&gt;{Math.round(weatherInfo.list[idx].main.temp - 273.85)} &amp;#8451; &lt;/td&gt;
              )
          }
      })}
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;humidity&lt;/td&gt;
      {weatherInfo.list.map((item,idx) =&gt; {
          while(idx &lt; displayItemTo &amp;&amp; idx &gt;= displayItemFrom){
              return(
                  &lt;td&gt;{weatherInfo.list[idx].main.humidity} % &lt;/td&gt;
              )
          }
      })}
  &lt;/tr&gt;
  </code></pre>
  
  <p>and there is few more rows a lot of repetition as you can see , so i thought of making this code shorter and simpler , than come up with idea of using this kind of function for that: </p>
  
  <pre><code>mapList(param){
      return () =&gt; {
          const weatherInfo = this.props.forecastData,
          {displayItemTo,displayItemFrom} = this.state;
  
          console.log('hello' + a);
  
          weatherInfo.list.map((item,idx) =&gt;{
              while(idx &lt; displayItemTo &amp;&amp; idx &gt;= displayItemFrom){
                  return(
                      &lt;td key={idx}&gt;weatherInfo.param&lt;/td&gt;
                  )
          }  
          });
      }
  }
  </code></pre>
  
  <p>and here i found issue , how to call the function or change it so after i gave a parameter it will go through the tree to prop i need , thought of using spread operator from ES6 , but dont have a clue how should i implement it. </p>