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

Intro to state in Compose: Android Basics with Compose #221

Open
uDanielBispo opened this issue Jul 24, 2024 · 1 comment
Open

Intro to state in Compose: Android Basics with Compose #221

uDanielBispo opened this issue Jul 24, 2024 · 1 comment

Comments

@uDanielBispo
Copy link

uDanielBispo commented Jul 24, 2024

URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-compose-using-state?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-using-state#4

In which task and step of the codelab can this issue be found?
Intro to state in Compose

Describe the problem
Hi! I do not really know if it is a problem, however I was following the step by step of this process and I have found a litlle problem:
image

In the codelab it says that you can use this code, but I got an error that prevented me to build the app, may be something that changed in the mean time that the codelab was created and I have satarted, anyway if it is not a problem, ok.

I already tried to use .value, still not working

I expect being useful

Steps to reproduce?

  1. it's just use the code on this codelab, it isn't working

Versions
Android Studio version: sorry, i am new on this, can't say
API version of the emulator: sorry, i am new on this, can't say

Additional information
Include screenshots if they would be useful in clarifying the problem.

@MohammedRAbed
Copy link

Maybe this is because you're initializing it inside a Composable function.
It'll work with no errors if you initialize it in a not-composable one, otherwise, you'll need to do it with the remember function.
PS: You might want to take a look at Understanding state in Compose from Interacting with UI and State pathway.

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

No branches or pull requests

2 participants