question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Components inside components

See original GitHub issue

This is a thread dedicated to discussing how we should compose components in the library / how we should encourage library users to do the same.

Case study: ButtonGroup component. Inspiration: https://www.futurelearn.com/pattern-library.

Expanding here in more detail soon…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
peterszerzocommented, Oct 9, 2017

Looking at all the conversations we have had so far, it seems that we’re starting to agree on the following (adding my own thoughts here and there, but we should discuss all of this):

  • explicitly using components within components is a preferred way to write API’s: <Tabs><Tab></Tab></Tabs> instead of <Tabs tabItems={[item1Data, item2Data]} />. Use React.Children.map and purchase several muffins for @Angarsk8.
  • refrain from using class names for styling the internals of a component (use props set on glamorous components instead). Sometimes this is necessary, and that’s ok, just use the prefix ‘co_’.
  • parent components sometimes need to override their children’s styles, like ButtonGroup does. In this case, we can add a class name like co_bgel to the children in the render method of the parent (see https://codepen.io/peterszerzo/pen/VMXQKO?editors=1010), and override using said class name. Class names prefixed by co_ will not cause styling conflicts with each other as they are all scoped, so we can keep them short and snappy.
0reactions
peterszerzocommented, Oct 4, 2017

Me too, I think it’s the best way to go. I suggest prefixing them with co_ or something.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React.js How to render component inside component?
React will only render the top-level custom components PageTop and PageBottom , as you already found out. The other components ( TopPlayers and ......
Read more >
React: Create component inside a component (?)
React: Create component inside a component (?) Here, the 'Users' component is re-rendering whole list whenever the search string changes. This ...
Read more >
Code Review: Avoid Declaring React Component Inside ...
Using uncontrolled components, access values of inputs via ref. After checking his code, I found that everything is fine, except for one major ......
Read more >
How to embed two components in one ... - GeeksforGeeks
React allows us to render one component inside another component. It means, we can create the parent-child relationship between the 2 or ...
Read more >
Components and Props - React
Components can refer to other components in their output. This lets us use the same component abstraction for any level of detail. A...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found