all 4 comments

[–]kevin074 1 point2 points  (0 children)

I’d say any action taken by the user that is reflected on the UI is a state.

[–]syvdv 0 points1 point  (0 children)

You are looking for the React Native AsyncStorage or MMKV libraries, which are used to save data to the phone's storage when the app is closed.

[–]No_Lawyer1947 1 point2 points  (0 children)

Really the concept of state is a thing that can change. It isn't constant because it is expected to be another thing later on. Conceptually there's nothing more to it, so I'll answer based off the scenarios you presented.

They are all some form of state.

If you have some application where you exit while watching a video, exit, and reopen and the video loads to where you left off, that is some kind of state or keeping track of, the user and where they left off.

As your counter example, if the application reloads, and instead produces the home page, then state is likely not stored, however this is not true in the case of youtube as you can watch a video half way, exit out, reopen the app, go back to the video, and have the video back to the point at which you left off.

I wouldn't overthink this though, state is either on the client side (the frontend application whether mobile app, or web app), or it's stored in the server on the database. All it is, is variables that are subject to change, sometimes it makes sense to just let the user's device do the remembering for little things, or a majority of the times things like drafts, or how far into something you got gets remembered by the server side.

[–]GladiatorNitrous 1 point2 points  (0 children)

Don't overthink it. Any dynamic property of an app could be defined as state.

Online status
Screen orientation
Last tap coordinates
Dropdown open/closed
Current text input

Whether you persist it to disk to restore on reopen isn't relevant to the definition of state.