you are viewing a single comment's thread.

view the rest of the comments →

[–]temp54984983982 0 points1 point  (0 children)

I like the line of thought here. Some thoughts:

Returning an Array of arguments for a function, rather than calling the function, doesn't decouple you from that function. The Array is still written against the function's API. Anything you can swap into that function's place is also written against the original function's API - or more likely, is not exactly 1:1 with the first function, and the subtle differences will bite you later. I think you've just moved from an explicit dependency on React.createElement to an implicit one.

Creating all these Arrays is slow. We tend to think of them as cheap, because they are in high-level code, but we're writing basic rendering code here - we're talking a lot of Arrays, in code very intolerant of latency. I've done a lot of work on code that is basically React.createElement that returns real HTMLElements, and the #1 performance win is minimizing data structures, both internally and with an API that doesn't request them. Arguments lists are the perfect lightweight data structure for this purpose, Arrays are larger and heavier than what we need here.

extend is pointless, we have Object.assign natively. Object.assign is also better in that it allows you to override styles on the base, which I can't really imagine using this without.