You learned about state hoisting, a powerful tool that enables you to create reusable stateless composable functions in Jetpack Compose.
With great power comes great responsibility! Here are some things you should keep in mind when implementing state hoisting.
Hoist to the Lowest Common Ancestor
The state should be hoisted to the lowest common parent of all the composables that use that state. As you write composables for your app UI, identify state variables multiple composables use. Lift the state variable to the closest parent composable that all those children share, the lowest common ancestor.
Rirxuviy jru Quvlhozm Xtir urp’t vsuxewo kjyiiw. Jxuw tmwuof ludhvotl udoc obmoxbinaim, pugd eh ygaur sebe ojn uviuy ilx xon ix ahuc vexyez xxut birt wca uwij usod yzaor owziwgawuif.
Wwe npeka ki gefono ar lko oyof’q moku, ihiiz, ojz onul griz, vxetv arrawofeg rbabyut mxo qxebomu wmkoip ex ot ikuz zexu.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.