a914-gowtham / compose-ratingbar

ratingbar composable for jetpack compose :rocket::star2:
MIT License
241 stars 21 forks source link

Cutom painter recomposition issue #38

Open vvdrak opened 1 year ago

vvdrak commented 1 year ago

This code has an excessive recomposition for the RatingBar when you type the text

@Composable
private fun Foo() {
    Column(modifier = Modifier.padding(20.dp)) {
        var rating by remember { mutableFloatStateOf(0f) }
        var feedback by remember { mutableStateOf("") }

        RatingBar(
            value = rating,
            painterEmpty = painterResource(id = R.drawable.ic_star_off),
            painterFilled = painterResource(id = R.drawable.ic_star_on),
            onValueChange = { rating = it },
            onRatingChanged = {}
        )
        TextField(value = feedback, onValueChange = { feedback = it })
    }
}

Painter is unstable param. Check SO for resolve this problem.

a914-gowtham commented 1 year ago

@vvdrak thanks. will fix this