With the view system example.
Each user interface element is an object containing an internal state that can be updated by calling
a setter or by modifying a property.
With Jetpack Compose, everything becomes different.
Composables are functions that receive as arguments the data they have to use to render the UI, and
when a data changes, the functions are executed again with the new arguments.
Later on, we'll talk about recomposition.
Let's create a new composable function.
I'll name it as counter.
I want from you to focus with me because it's very important concept you should master in Jetpack Compose.
VAR count equals to zero.
I'll create a text or a column at first, and inside this column I'm going to create the first composable,
which is the counter, and the second composable which is a button.
This button will increase the count by one every time the user click on it.
So count plus plus and the text of the button would be increase counter.
Now let me call this method inside the set content method and run our application.
And here we go.
We're happy with this application.
Let's increase the counter by clicking on this button.
Click on it.
But oops, the counter is not increasing despite we write everything correct, but the counter is not
increasing here.
Your code will not work because you should note that not all values will initiate a recomposition when
they change.
Only states can do that, so you can't use this variable.
And if you if you notice the count, it will increase the count variable.
It will increase normally but it will not update the state.
I'll show you how to discover the count value here.
On click I'm going to add a log v tag and I'll set the counter value to count.
Let's run our application again and open Logcat search for tag.
Increase the counter and you can see in the logcat the counter value is one.
Counter value two, three, four, five and so on.
On each click we are increasing the counter value, but the text here is not updating.
You should note that not all values will initiate a decomposition when they change.
Only states can do.
I want from you to write this down to understand the importance of using state in Jetpack Compose.
So again guys, I want from you to understand what we did.
We created this application.
If we increase the counter, it will increase the count value variable, but it will not update the
UI.
So we're going to use the state to solve this problem.
In the next video, we're going to use the state in order to update the UI on each click.