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
2
votes
3 answers

Optimize updating redux state

I have a web application that received an update from websocket, like 100 messages per second. I am using immutable helper and tried this const parentIndex = action.payload.data.findIndex( i => i.id===action.id) if(parentIndex !== -1) { const…
sinnede
  • 83
  • 7
2
votes
1 answer

Using class property to set initial state in React

I have a React class component that with an initial state object in the constructor call. I originally just had an object literal assigned to this.state, but I need to share the initial state object with other methods in the class to reset the…
gubawhips
  • 65
  • 5
2
votes
2 answers

Override index array from API result

Having a problem overriding the index of array in redux state :/ I am receiving a data from an endpoint and the results are: e.g. data: [{ 0: {id: 123, name: test1 }, 1: {id: 456, name: test2 }, 3: {id: 789, name: test3 }, }] But I…
sinnede
  • 83
  • 7
2
votes
2 answers

Flutter: Widget State: Is this code safe?

The code below is an example to illustrate this question. The code below works, however the following line: class WidgetCustom extends StatefulWidget { has "WidgetCustom" underlined in green in vsCode, and when the cursor is positioned over it, it…
Brian Oh
  • 9,604
  • 12
  • 49
  • 68
2
votes
0 answers

Flutter Push and Pop returning to wrong screen when browsing category lists and Bloc

So framework of an app consuming an api and i'm getting there. I have a category browse screen you can tap a cat and then browse then next level down and there's an AppBar provided back button. The issue is that i push to the next category screen,…
paulinventome
  • 1,047
  • 2
  • 10
  • 11
2
votes
0 answers

How to change route on angular ui-router without ngOnInit being called?

I have an angular 7 application using a angular ui-router@2.0.2 where I need to switch between views while maintaining the state of the views all the while. I dont want ngOnInit to be called upon each route change, I'd rather want the views (even…
2
votes
3 answers

Passing state values between files

I am having trouble passing the values of state from one file to another. I need to do this because when I get to pulling information from the DB, it will need to display more details about these values. I have a FlatList that when is clicked it…
Felis
  • 49
  • 4
2
votes
2 answers

React-redux nested state, working with nested arrays

I'm trying to work with multiple levels of nested arrays with redux state and am running into complexity (or comprehension :)) issues. I've just started learning react (with redux) and think I am making this too complex and not modeling the state…
weznagwama
  • 49
  • 5
2
votes
1 answer

How to fix Do not mutate state directly. Use setState() with array?

I have an array tranches: [{ start: moment().format("HH:mm"), end: moment().format("HH:mm") }] and when I set the value of the tranches[0].start without setState I get : Do not mutate state directly. Use setState() My code is : handleAjouter =…
Ichrak Mansour
  • 1,850
  • 11
  • 34
  • 61
2
votes
2 answers

React functional component with useState hook executes function immediately

I have a functional React component with useState hooks, and I have an array with five textinput fields. The values of the input fields are registered in the state in an array. The problem is, that I want to update the inputfields array with an…
MMMM
  • 3,320
  • 8
  • 43
  • 80
2
votes
3 answers

how to save the state in userdefaults of accessory checkmark-iphone

I am working on an application having UItableView. In the rows of the table i am able to put checkmarks.Now how to save the state of checkmarks so that even if user close the application the state should be shaved and in the next launch of…
maddy
  • 4,001
  • 8
  • 42
  • 65
2
votes
2 answers

How to pass variable from stateful widget class? - flutter

I have a string that contains an information that was passed from previous classes. But i need to use that variable in the state class. Class of stateful widget that contains the information (String text): class CreateLevelScreen extends…
irongirl
  • 895
  • 7
  • 14
  • 31
2
votes
1 answer

Why add state value to variable before return within render

I often see the following pattern used within JavaScript classes and React. class Welcome extends React.Component { state: { someValue: 1 } render() { const myValue = this.state.someValue; return

Hello, {myValue}

; …
2
votes
1 answer

How can I set a randomized initial state using a conditional and React Hooks?

This example simulates a coin toss. I would like to randomize the initial state of the coin. The first time the page is loaded it could show heads. The next time, tails. To do so, I am using a random number generated by the Math method and a…
Jacob Crocker
  • 75
  • 1
  • 7
2
votes
2 answers

React userReducer init function not triggering on props update

I have a component which is a form which I use to create records in my database. I also want to be able to pass into this component values with which to populate the form, allowing me to then update my existing database records. Straightforward…
iiz
  • 691
  • 1
  • 10
  • 26
1 2 3
99
100