Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hoist state changing of screen #1675

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

veyndan
Copy link
Contributor

@veyndan veyndan commented Nov 9, 2023

Per the documentation, It's bad practice to pass MutableState's down as parameters. Per their guidance, the parameter has been split between two: screen and onScreenChange.

@@ -44,12 +45,11 @@ class TestContext(

@Composable
fun TestApp(context: TestContext) {
val screenKeyState = rememberSaveable { mutableStateOf<String?>(null) }
val screenKey = screenKeyState.value
var screenKey by rememberSaveable { mutableStateOf<String?>(null) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using property delegation to reduce the risk of this happening again.

Per [the documentation](https://developer.android.com/jetpack/compose/state#state-hoisting), It's bad practice to pass `MutableState`'s down as parameters. Per their guidance, the parameter has been split between two: `screen` and `onScreenChange`.
@veyndan veyndan force-pushed the veyndan/2023-11-09/hoist-screen-change branch from 5efbe41 to c40afc7 Compare November 9, 2023 12:20
@veyndan veyndan merged commit 570229d into trunk Nov 9, 2023
8 checks passed
@veyndan veyndan deleted the veyndan/2023-11-09/hoist-screen-change branch November 9, 2023 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants