Questions tagged [state]

The contents of memory locations, at any given point in the program's execution, is called the program's state.

The contents of memory locations, at any given point in the program's execution, is called the program's state.

More information is available on Wikipedia.

6971 questions
892
votes
12 answers

See :hover state in Chrome Developer Tools

I want to see the :hover style for an anchor I'm hovering on in Chrome. In Firebug, there's a style dropdown that allows me to select different states for an element. I can't seem to find anything similar in Chrome. Am I missing something?
Ben
  • 11,249
  • 5
  • 15
  • 12
603
votes
17 answers

How to declare global variables in Android?

I am creating an application which requires login. I created the main and the login activity. In the main activity onCreate method I added the following condition: public void onCreate(Bundle savedInstanceState) { …
Niko Gamulin
  • 63,517
  • 91
  • 213
  • 274
344
votes
17 answers

Updating an object with setState in React

Is it at all possible to update object's properties with setState? Something like: this.state = { jasper: { name: 'jasper', age: 28 }, } I have tried: this.setState({jasper.name: 'someOtherName'}); and this: this.setState({jasper: {name:…
JohnSnow
  • 4,775
  • 7
  • 16
  • 37
341
votes
25 answers

React: how to update state.item[1] in state using setState?

I'm creating an app where the user can design his own form. E.g. specify name of the field and details of which other columns that should be included. The component is available as a JSFiddle here. My initial state looks like this: var DynamicForm =…
martins
  • 7,647
  • 6
  • 41
  • 67
286
votes
18 answers

How can you do anything useful without mutable state?

I've been reading a lot of stuff about functional programming lately, and I can understand most of it, but the one thing I just can't wrap my head around is stateless coding. It seems to me that simplifying programming by removing mutable state is…
Mason Wheeler
  • 77,748
  • 42
  • 247
  • 453
257
votes
10 answers

How to prevent custom views from losing state across screen orientation changes

I've successfully implemented onRetainNonConfigurationInstance() for my main Activity to save and restore certain critical components across screen orientation changes. But it seems, my custom views are being re-created from scratch when the…
Brad Hein
  • 10,689
  • 11
  • 48
  • 71
248
votes
3 answers

React.Component vs React.PureComponent

The official React docs state that "React.PureComponent's shouldComponentUpdate() only shallowly compares the objects", and advises against this if state is "deep". Given this, is there any reason why one should prefer React.PureComponent when…
semuzaboi
  • 4,414
  • 4
  • 16
  • 32
187
votes
9 answers

Where to write to localStorage in a Redux app?

I want to persist some parts of my state tree to the localStorage. What is the appropriate place to do so? Reducer or action?
Marco de Jongh
  • 4,604
  • 3
  • 15
  • 29
165
votes
4 answers

Does React keep the order for state updates?

I know that React may perform state updates asynchronously and in batch for performance optimization. Therefore you can never trust the state to be updated after having called setState. But can you trust React to update the state in the same order…
darksmurf
  • 3,029
  • 5
  • 20
  • 31
147
votes
2 answers

AngularJS ui router passing data between states without URL

I am facing this problem of passing data between two states without exposing the data in the url, it's like user cannot really directly land on this state. For example. I have two states "A" and "B". I am doing some server call in state "A" and…
vijay tyagi
  • 2,197
  • 3
  • 17
  • 30
141
votes
8 answers

Advantages of stateless programming?

I've recently been learning about functional programming (specifically Haskell, but I've gone through tutorials on Lisp and Erlang as well). While I found the concepts very enlightening, I still don't see the practical side of the "no side effects"…
Sasha Chedygov
  • 116,670
  • 26
  • 98
  • 110
137
votes
3 answers

How to add a custom button state

For instance, the default button has the following dependencies between its states and background images:
Vit Khudenko
  • 27,639
  • 10
  • 56
  • 86
129
votes
5 answers

android fragment onRestoreInstanceState

Am I missing something or do Fragments not have a onRestoreInstanceState() method? If not, how do I go about attaining something similar?
Shaun
  • 5,293
  • 10
  • 37
  • 48
128
votes
6 answers

Vuex state on page refresh

My app uses the Firebase API for User Authentication, saving the Login status as a boolean value in a Vuex State. When the user logs in I set the login status and conditionally display the Login/Logout button accordingly. But when the​ page is…
boomboxboy
  • 1,884
  • 5
  • 16
  • 29
123
votes
6 answers

React.js, wait for setState to finish before triggering a function?

Here's my situation: on this.handleFormSubmit() I am executing this.setState() inside this.handleFormSubmit(), I am calling this.findRoutes(); - which depends on the successful completion of this.setState() this.setState(); does not complete before…
malexanders
  • 2,403
  • 4
  • 16
  • 42
1
2 3
99 100