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.

9107 questions
28
votes
3 answers

Which algorithms are hard to implement in functional languages?

I'm dabbling in functional languages and I have found some algorithms (especially those that use dynamic programming) harder to write and sometimes less efficient in worst case runtime. Is there a class of algorithms which are less efficient in…
27
votes
3 answers

react / functional component / props changed / getDerivedStateFromProps

Lets say I'm doing a simple CRUD app in react. My functional component is basically just the form. In the CREATE case I pass in an empty object via props In the UPDATE case I pass in an object with the values via props (I got the data in the parent…
Thread Pitt
  • 716
  • 1
  • 6
  • 20
27
votes
10 answers

Nullable bool as tri-state variable in C#

Is there any merit to using a nullable bool to store a tri-state value? For example, null == 1st state, false == 2nd state, true == 3rd state? The overhead is probably higher than using a byte enum, but I'm curious.
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
27
votes
2 answers

You attempted to set the key on an object that is meant to be immutable and has been frozen

In the following example: MapView displays elements of a ListView as annotations Clicking on a ListView element should result in painting it in blue color. Bonus if the MapView and ListView efficiently use the state object Modifying the…
Peter G.
  • 7,816
  • 20
  • 80
  • 154
27
votes
5 answers

Trouble understanding Object State, Behavior, and Identity?

I have been instructed by my professor to introduce myself on a page as if I were an object, and that I must address three things: 1) Object State, 2) Behavior, and 3) Identity. However, I am still really confused as to how I would go about doing…
TheNewGuy
  • 411
  • 1
  • 7
  • 13
26
votes
4 answers

Huge React State Array with Hundreds of Inputs, slow state changes onChange

I'm trying to a large React form, but each input in the form is complex and has a complex state. I keep the state of all of the inputs in a parent component, and each input is wrapped in a child component. I have a state array in parent that…
andul007
  • 263
  • 1
  • 4
  • 5
26
votes
3 answers

react this.props undefined or empty object

Building a small react app that passes the geolocation (determined by the browser to a child component as props). The first component: App.jsx import React, {Component} from 'react'; import DateTime from…
chinds
  • 1,761
  • 4
  • 28
  • 54
26
votes
6 answers

Checkbox still checked hitting the back button, but it has no "checked" attribute

I am working on a checkbox-based filter for a e-commerce. Everything works fine but when I attempt to go back via the back button, the checkboxes still checked without any checked attribute. I noticed that this "issue" is occurring on…
Valérian Polizzi
  • 453
  • 1
  • 4
  • 10
26
votes
4 answers

QTcpSocket state always connected, even unplugging ethernet wire

I have a QTcpSocket and I am reading into a loop. Each time a full packet has been read, or there has been an error, I manually check the status of the socket inside the loop, with: while(true){ …
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
25
votes
4 answers

How to access state when component unmount with React Hooks?

With regular React it's possible to have something like this: class NoteEditor extends React.PureComponent { constructor() { super(); this.state = { noteId: 123, }; } componentWillUnmount() { …
laurent
  • 88,262
  • 77
  • 290
  • 428
25
votes
7 answers

Naming Convention for State / Region / Province

I am building a class that represents a US State or Canadian Province. What should the class be called? Some ideas: Region: Problem with this is that .Net has a RegionInfo class that uses the term Region to represent a country (and not a State or…
Alex Czarto
  • 3,151
  • 4
  • 28
  • 28
25
votes
3 answers

How to listen to localstorage in react.js

I'm having a problem with a component that gets data from an array in localstorage. It gets the initial data when the page loads, but how do I update when localstorage is changed? import React, {Component} from 'react'; class MovieList extends…
jermain joseph
  • 351
  • 1
  • 3
  • 6
25
votes
8 answers

How to check for broken images in React JS

I'm writing a module that takes article data from json and shows a large image over the article text, a hero module as they say. I've got the data and have set it up so if there is an image, it will show that image and if there is no image in the…
nyhunter77
  • 614
  • 2
  • 7
  • 19
24
votes
4 answers

What is application state?

This is a very general question. I am a bit confused with the term state. I would like to know what do people mean by "state of an application"? Why do they call webserver as "stateless" and database as "stateful"? How is the state of an application…
sethu
  • 1,691
  • 4
  • 22
  • 34
23
votes
5 answers

Functional Reactive F# - Storing States in Games

I am a student currently learning about Functional Reactive paradigm using F#. It's radically new viewpoint for me. Yesterday I learned about creating a simple ping-pong game using this paradigm. The idea I grasp so far is : we think values as…
user248836
  • 245
  • 2
  • 5