DEV Community

Discussion on: Conditionally render react components in cleaner way

Collapse
 
jwp profile image
John Peters

Clever...

{roleSettings(username)[userRole]}
Enter fullscreen mode Exit fullscreen mode

Thanks!

Collapse
 
skyjur profile image
Ski • Edited

Clever is not a compliment in code and this example is not one that anyone should follow. Simple not clever is what we want.

Collapse
 
jwp profile image
John Peters

You mean function compositional patterns are ugly? I just stated it was clever because it took me a while to understand it.

Thread Thread
 
danielo515 profile image
Daniel Rodríguez Rivero

This is not about function composition, it is that you need to parse and execute the code in your head to understand what the outcome will be. Exactly the opposite as what declarative means.

Thread Thread
 
jwp profile image
John Peters

Be nice, I just got out of 3rd grade last year. My point is both functional composition and what was shown are similar with the confusion factor. The only difference is there is plenty of raving going out about the beauty of functional composition.

Thread Thread
 
danielo515 profile image
Daniel Rodríguez Rivero

I don't know where do you get that my answer was not nice, but I assure you I was not pretending to be aggressive.
I am a big fan of functional composition, but years and experience taught me that the code I want to debug is the simplest possible one. So I only use functional composition when it really improves simplicity or doesn't hurt maintainability. In this article, none of those are met.