title: How to access next/prev object inside map - react?
body: <p>I have problem with generate next/prev link inside specific object.
  It's my code.</p>
  
  <pre><code>someArrCars = [{name: 'somecar1', link: 'somelink1', vin: '123'}, {name: 'somecar2', link: 'somelink2', vin: '345'},...];
  
  </code></pre>
  
  <p>generate route:</p>
  
  <pre><code>someArrCars.map( el =&gt; &lt;Route path={el.link} component={() =&gt; &lt;OnePageCar carVin={el.vin} key={el.vin}/&gt;}
  
  </code></pre>
  
  <p>generate links prev/next inside one object</p>
  
  <pre><code>import React, { Component } from "react";
  
  export default class OnePageCar extends Component {
    render() {
      const { carVin } = this.props;
  
      someArrCars.map((el, index) =&gt; {
        if (el.vin === carVin) {
          return (
            &lt;React.Fragment key={el.vin}&gt;
              {someArrCars
                .slice(index - 1, -(someArrCars.length - index))
                .map(el =&gt; (
                  &lt;Link src={el.link} /&gt;
                ))} {/* &lt;== prev*/}
              {someArrCars
                .slice(index + 1, -(someArrCars.length - index - 2))
                .map(el =&gt; (
                  &lt;Link src={el.link} /&gt;
                ))} {/* &lt;== next*/}
            &lt;/React.Fragment&gt;
          );
        }
      });
    }
  }
  
  </code></pre>
  
  <p>I know it's a little crazy idea, but I don't know how to do it in another way...</p>