wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

forbid rt-repeat in root nodes #171

Closed nippur72 closed 8 years ago

nippur72 commented 8 years ago

since rt-repeat containing tags are emitted as an array, they can't be root nodes, because React wants the result of the render function be an actual component, not an array of components.

Example:

<div rt-repeat="a in [1,2,3]">{a}</div>

is translated into:

var templateRT = function () {
    function repeatA1(a, aIndex) {
        return React.createElement('div', {}, a);
    }
    return _.map([1, 2, 3], repeatA1.bind(this));
};

but the following error is thrown when used:

Invariant Violation: Constructor.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.