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
121
votes
7 answers

Remove the complete styling of an HTML button/submit

Is there a way of completely removing the styling of a button in Internet Explorer? I use a css sprite for my button, and everything looks ok. But when I click the button, it moves to the top a little, it makes it look out of shape. Is there a css…
Saif Bechan
  • 14,061
  • 22
  • 74
  • 122
120
votes
18 answers

How to save RecyclerView's scroll position using RecyclerView.State?

I have a question about Android's RecyclerView.State. I am using a RecyclerView, how could I use and bind it with RecyclerView.State? My purpose is to save the RecyclerView's scroll position.
陈文涛
  • 1,203
  • 2
  • 9
  • 5
118
votes
10 answers

React setState not updating state

So I have this: let total = newDealersDeckTotal.reduce(function(a, b) { return a + b; }, 0); console.log(total, 'tittal'); //outputs correct total setTimeout(() => { this.setState({dealersOverallTotal: total}); },…
The worm
  • 3,578
  • 10
  • 26
  • 44
117
votes
8 answers

setInterval in a React app

I'm still fairly new at React, but I've been grinding along slowly and I've encountered something I'm stuck on. I am trying to build a "timer" component in React, and to be honest I don't know if I'm doing this right (or efficiently). In my code…
Jose
  • 3,591
  • 6
  • 23
  • 40
93
votes
7 answers

React - setState() on unmounted component

In my react component im trying to implement a simple spinner while an ajax request is in progress - im using state to store the loading status. For some reason this piece of code below in my React component throws this error Can only update a…
Marty
  • 3,107
  • 4
  • 28
  • 44
89
votes
1 answer

Isn't Redux just glorified global state?

So I started learning React a week ago and I inevitably got to the problem of state and how components are supposed to communicate with the rest of the app. I searched around and Redux seems to be the flavor of the month. I read through all the…
Ryan Peschel
  • 9,095
  • 18
  • 57
  • 101
83
votes
8 answers

How to Set/Update State of StatefulWidget from other StatefulWidget in Flutter?

For Example in the below code plus button works and able to update the text but the minus button does not. But if we press FloatingActionButton then the State is refreshed . The minus button is changing the value of the variable but not updating…
Ajay Kumar
  • 9,400
  • 8
  • 40
  • 48
79
votes
3 answers

Preserving global state in a flask application

I am trying to save a cache dictionary in my flask application. As far as I understand it, the Application Context, in particular the flask.g object should be used for this. Setup: import flask as f app = f.Flask(__name__) Now if I do: with…
Profpatsch
  • 4,338
  • 5
  • 25
  • 30
78
votes
11 answers

What is the best way to add a value to an array in state

I have an array in state, let's say this.state.arr. I want to add something to this state property, and then change some more properties. Option 1 onChange(event){ this.state.arr.push('newvalue'); ... …
Flion
  • 9,051
  • 12
  • 40
  • 61
75
votes
11 answers

React setState not Updating Immediately

I'm working on a todo application. This is a very simplified version of the offending code. I have a checkbox:

Writing Item

Here's the function…
lost9123193
  • 7,498
  • 18
  • 49
  • 87
74
votes
3 answers

Why give an "abstract: true" state a url?

I've be fiddling around with ui-router today in trying to better understand the scaffolding in Ionic and one thing that I noticed was that they give the abstracted state of "tabs" a url. The only times I've ever used abstract states, I used an…
spb
  • 3,278
  • 5
  • 19
  • 26
72
votes
3 answers

Where Should Model State Be Stored In Angular.js

I'm finding Angular's use of models confusing. Angular seems to take the approach that a model can be anything you like - I.E. Angular does not include an explicit model class and you can use vanilla JavaScript objects as models. In almost every…
Undistraction
  • 38,727
  • 46
  • 165
  • 296
69
votes
6 answers

Where can I get a list of Countries, States and Cities?

This probably seems like a duplicate, since there are identical questions out there. Unfortunately all of the answers to all of these questions are missing one detail: the states. Where can I get a list of countries, states and cities? For example,…
Jonathan
  • 29,612
  • 37
  • 126
  • 201
66
votes
8 answers

Does C++ support compile-time counters?

For the purpose of introspection, sometimes I've wanted to automatically assign serial numbers to types, or something similar. Unfortunately, template metaprogramming is essentially a functional language, and as such lacks global variables or…
Potatoswatter
  • 126,977
  • 21
  • 238
  • 404
65
votes
2 answers

pushState: what exactly is the state object for?

I've read a dozen of times now that the state object could exists of multiple key|value pairs and that it is associated with the new history entry. But could someone please give me an example of the benefits of the state object? Whats the practical…
campari
  • 875
  • 2
  • 8
  • 11