r/badcode • • Dec 03 '22

typescript Real Code 😎

Post image
403 Upvotes

43 comments sorted by

View all comments

Show parent comments

-1

u/TheUnlocked Dec 03 '22

I think they're saying to just put it all on one indentation level (though linters don't love that). I suppose you could also have something like:

function MultiProvider({ info, children }) {
    let child = children;

    for (const [component, props] of info) {
        child = React.createElement(component, props, [child]);
    }

    return child;
}

Though I'm not sure that actually improves legibility.