Hello All, How to `reuse` Custom `OutlineTextField...
# compose
s
Hello All, How to
reuse
Custom
OutlineTextField
composable?. For ex - I have same repeating
OutlineTextField
component imagine 4 - 5 fields. Only thing I need to change is to
remember state
for each Input field. How to achieve this? Same I need to achieve for
Sliders
This is component 👇
z
Unsure if I understand you correctly but what you want is "hoisting". Essentially you create a function that accepts the current value, a callback function and an optional modifier
pseudo code: fun MyCustomTextField(value: String, onValueChanged: (String) -> Unit, modifier: Modifier = Modifier()) { // attach modifier from parameters to OutlineTextField and append your
fillMaxWidth
etc. // your code code onValueChange = onValueChanged } https://developer.android.com/jetpack/compose/state#state-hoisting
s
It’s working fine 👍
Thank you!