Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When I'm not using JSX, I often do something like this

    const define = (componentDefinition) => (props, ...children) => isReactNode(props) ? React.createElement(componentDefinition, {}, props, ...children) : React.createElement(componentDefinition, props, ...children);
    const elements = new Proxy({}, {get: (target, tagName, _) => define(tagName)});
    // ...
    const {div, h1, button, input} = elements;
But although I really disliked JSX at first, once I tried it a little, I realised that it's about making the code describe what you want rather than how to get it. That mind set shift is actually valuable, even if underneath it's still turning into function calls.


Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: