wix-incubator / react-templates

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

emit pure ES6 render function #156

Open nippur72 opened 8 years ago

nippur72 commented 8 years ago

with a specific command line switch we could have a pure ES6 output, with scopes emitted as lambda expressions instead of functions. E.g.:

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

The benefit of this could be injecting the render function into the component class source code, and have it syntax checked by the IDE/compiler (I'm thinking mostly of TypeScript).

So for example if you mispell {this.someProp} in your template code, that could be detected by the compiler because it knows exactly what's in this.