Hacker News new | ask | show | jobs
by mlsarecmg 3371 days ago
Only for someone who has never seen JSX, and for very simple cases. For anything that goes deeper you have to break the pre-made HTML conditionals and circumvent. For instance the horror an Angular uses goes through to loop an object with "pipes" which are now defined in separate files, whereas everyone else would use Object.keys and that's that. I often wonder, where are the actual benefits with templates, all i can see from using them are critical downsides.

Do this in a template for instance:

    import range from 'lodash/range'
    
    const Item = ({ number }) => <li>{number}</li>
    const App = () => (
        <ul>
            {range(0, 20, 5)
                .map(index => 
                    <Item number={index} />
                )
            }
        </ul>
    )
Templates can't even resolve <Item> because they don't know scope. The have no access to `range` either. Instead we're now hacking around with template registrations and injections. This results in a mess of functionality sprinkled all over the place for no good reason.