Can someone explain to me why after upgrading to compose stable this code would fire the sideeffect twice after launching the app
Copy code
SideEffect {
viewModel.getPlatforms()
}
In other words viewModel.getPlatforms fires twice where as it didn’t use to be the case before. Perhaps I was misusing the api before
o
Oleksii Yerastov
08/20/2021, 5:52 PM
SideEffect is triggered every time recomposition of your composable happens. If you want to run some code only once during lifetime of your composable use LaunchedEffect instead.
☝🏻 1
a
Abhishek Dewan
08/20/2021, 5:55 PM
Ahh I thought as much. I never ran into the problem before so assumed I was using it correctly. Thanks for letting me know