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

SavedStateHandle instance not the same as in NavBackStackEntry #1815

Open
alex-kor opened this issue Mar 8, 2024 · 1 comment
Open

SavedStateHandle instance not the same as in NavBackStackEntry #1815

alex-kor opened this issue Mar 8, 2024 · 1 comment

Comments

@alex-kor
Copy link

alex-kor commented Mar 8, 2024

Describe the bug
Trying to update SavedStateHandle which is accessible from NavBackStackEntry, and then read those values from a ViewModel which has a SavedStateHandle, and I see no values in there. Checked the instance ID and I see that ViewModel has different instance than a NavBackStackEntry. Question is how to get the same instance. I have a workaround which is working fine, but it would be nice to have it resolved and not jumping arround.

To Reproduce
make a composable navGraph with 2 routes. When navigating from route 1 to 2 update savedStateHandle the way like so:

backStackEntry.savedStateHandle[PRODUCT_FAMILY_NAME_PARAM] = "test data"

then inside a ViewModel try to read it like so

checkNotNull(savedStateHandle[PRODUCT_FAMILY_NAME_PARAM])

Expected behavior
I should get a "test data" string but get nothing

Koin module and version:
koin-core:3.4.3

Snippet or Sample project to help reproduce
Add a snippet or even a small sample project to hel reproduce your case.

@timonmw
Copy link

timonmw commented Mar 21, 2024

I have the same Problem. What is your workaround?

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