Skip to content

How to instert data from jetpack compose to mongo database? #62685

Answered by dominayo
Doraemon730 asked this question in Mobile
Discussion options

You must be logged in to vote

Accessing and editing ViewModel variables from your views is a very bad practice. Here's another way to temporarily save values till the user goes to the next screen: Use the remember API to save the states of the TextFields between recompositions. At the Button's click, you then call the save function you have at the ViewModel.

var name by rememberSaveable { mutableStateOf("") }
var phoneNumber by rememberSaveable { mutableStateOf("") }

OutlinedTextField(
value = name,
onValueChange = { name = it },
...
)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rady5335
Comment options

Answer selected by Doraemon730
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Mobile
Labels
Mobile Triage your notifications and browse code on the go with the GitHub Mobile app Question
3 participants