Should I annotate my modifiers with `@Stable`? Als...
# compose
s
Should I annotate my modifiers with
@Stable
? Also, is it fine to make a modifier composable?
a
no, you don’t need it this annotation in most cases. we still experimenting with it by adding it on some of our modifiers.
Modifier.yourModifierName()
function shouldn’t be composable according to our guidelines. instead you can use
Modifier.yourModifierName()  = composed { …your code }
which allows you to have a composable factory. When you use it the real composable would be invoked right on the applied Layout. imagine if you apply the same modifier object for two Layouts, in this case they will not share the same state
1
s
Okay so both the customModifiers in this case will have different states, right?
Copy code
Box {
    Image(customModifier)
    Image(customModifier)
}

Modifier.customModifier = composed {
   // some state
}
a
yes
👍 1