Skip to content

Is it possible to use a component into anothers without adding it as a child? #573

Answered by arkivanov
Shahriyar13 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the detailed description. I believe there could be multiple solutions.

  1. The first solution that comes to mind is to extract CompX and CompY into a separate component (say CompXY). CompXY would have its own Child Slot, Config and Child sealed classes. Then you could just reuse CompXY in all your Comp01, Comp11, Comp12, etc. You can also have separate CompXYContent Composable function with bottom sheets.
  2. Another solution could moving CompX and CompY to MainComp. But this again depends on the use case.
  3. It is also possible to extract Config and Child sealed classes for CompX and CompY somewhere in common place. Then you will only need to use childSlot function in hosting components…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Shahriyar13
Comment options

@arkivanov
Comment options

Answer selected by Shahriyar13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants