<#CJLTWPH7S|compose> Hey guys, if we have a compos...
# compose
s
#compose Hey guys, if we have a compose component which gets two or more modifier, how should we handle it ? I mean the naming of modifiers while lint complains changing the name of modifier parameter
s
Why does it take two modifiers in the first place?
1
c
Yes, if you are taking two of them as parameters to apply to a single element you should just chain them and pass one. If you are taking two to use on different elements it seems those different elements should be different composables.
s
Thanks guys for your answers Here is the stackOverFlow’s link There I asked my question with sample code so you can have better view to understand what I mean exactly. Thanks in advance for your help
c
So in your specific snippet with ConstraintLayout, I don’t think you need to pass
layoutId
modifiers down to the Composables because unless you are using them to reference for setting constraints, I don’t think they are being used at all in CompletionSection. How are you using those? That modifier is useful for custom layouts or with saving them in a variable to reference for creating constraints in ConstraintLayout.
My point is based on your snippet, it doesn’t seem those modifiers are being used in a meaningful way in the CompletionSection composable, so you could just pass the strings (“completedIcon”, “newTextField”) as string parameters instead, and then declare the
layoutId
modifier in the CompletionSection function
s
They are working @Chris Sinco [G] well It is a complicated component which becomes very long method so I used decoupled constraintset approach and to avoid making function so long related part became separated functions
s
I’d still say that you either want those modifiers for the child components to be driven from normal input parameters provided to the function or can use some sort of slot API for those items. I’d love to see the code where you call
CompletionSection
to get a better understanding of what kind of situation you can find yourself into to not be able to shape the API that way.
1