React guidelines - Passing icon as props #1382
Closed
lucasbordeau
started this conversation in
Engineering vision
Replies: 1 comment
-
Reopen if conversation is still relevant @lucasbordeau ;) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This discussion is about how to pass icon components as props.
Let's focus on this specific use case and not the global discussion of how to pass components as props because right now it's mainly about passing icons in different parts of the app.
Drawing from this nice article about the different ways to do it : https://www.developerway.com/posts/react-component-as-prop-the-right-way#part2
And also about the React documentation : https://react.dev/reference/react/cloneElement
I think we should avoid using cloneElement, because :
We could use only uninstanciated components as props, to have balance between flexibility and a simple API :
Example :
We should try to avoid manipulating the DOM at a low level, and open discussions about it for very specific use cases that could arise in the future, not as a general discussion, this way we keep a low surface API and code guideline that everybody can follow easily.
Beta Was this translation helpful? Give feedback.
All reactions