ReactJs strange error: Syntax error: Unexpected token (26:39)
<p>This is my example code. I am just trying to execute some code from react documentation. I am trying ti render doubled list of numbers:</p>

<pre><code>import React, { Component } from 'react';

class ListKeysComponent extends Component {
    constructor(props) {
        super(props);

        const numbers = [1, 2, 3, 5, 8, 13];
        const doubled = numbers.map((number) =&gt; number * 2);

        this.state = {
            numbers: numbers,
            doubled: doubled
        };
    }

    render() {
        if (this.state.value &gt; 2000) {
            return null;
        }

        // render numbers in list elements

        return (
            &lt;div&gt;
                &lt;ul&gt;
                    for (var i = 0; i &lt;= 5; i++) {
                        &lt;li&gt;{this.state.numbers[i]}&lt;/li&gt;
                    }
                &lt;/ul&gt;
            &lt;/div&gt;
        );
    }
}
</code></pre>

<p>But I am not understanding why this code is generating this error message:</p>

<pre><code>Failed to compile.

Error in ./src/ListKeysComponent.js
Syntax error: Unexpected token (26:39)

  24 |             &lt;div&gt;
  25 |                 &lt;ul&gt;
&gt; 26 |                     for (var i = 0; i &lt;= 5; i++) {
     |                                        ^
  27 |                         &lt;li&gt;{this.state.numbers[i]}&lt;/li&gt;
  28 |                     }
  29 |                 &lt;/ul&gt;

 @ ./src/App.js 22:25-55
</code></pre>

<hr>

<p><strong>edit: the solution from <a href="https://stackoverflow.com/questions/22876978/loop-inside-react-jsx">loop inside React JSX</a></strong></p>

<pre><code>render() {
    if (this.state.value &gt; 2000) {
        return null;
    }

    var numrows = this.state.numbers.length;
    var list = []
    for (var i = 0; i &lt; this.state.numbers.length; i++) {
        list.push(&lt;li&gt;{this.state.numbers[i]}&lt;/li&gt;);
    }

    return (
        &lt;div&gt;
            &lt;ul&gt;
                {list}
            &lt;/ul&gt;
        &lt;/div&gt;
    );
}
</code></pre>