|
|
|
|
|
by gcmeplz
1122 days ago
|
|
I think sometimes "clever" is just a term for bad code that you don't like. The clever-code react example doesn't seem like a good example of clever code to me—it just seems awful! If you were do something clever for that function, it could look like this: function extractDataFromResponse ([Component, props]) {
return _.pickBy({Component, props}, Boolean);
}
I'm cheating by using lodash, but I think this code is a fairer comparison to the unclever example that's given in the article. |
|
Here’s my version of the “clever” example that doesn’t depend on Lodash. It’s longer than your version but still simpler than the article’s: