Pick the fix
A WebView inside Compose reloads on every recomposition. What's wrong?
Hint 1 of 1
Which lambda runs once?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A The WebView is created in update; create it in factory and only change it in update
Correct. factory runs once; update runs every recomposition.
Why not the others?
- B AndroidView can't host WebView. It can; that's what it's for.
- C Add
rememberaround the url. The url isn't the problem; the View is recreated. - D Use
LaunchedEffectto load the page. That doesn't stop the View being recreated.