Questions tagged [state]
The contents of memory locations, at any given point in the program's execution, is called the program's state.
8,410
questions
1
vote
0
answers
23
views
Conditional Operator for React Components, not updating
I currently have 2 Components that work conditionally, but i would like it to update and change
when the createdSavingsGoal state array is greater than 0 (i.e Not empty)
Then it shows a List.. When ...
0
votes
1
answer
18
views
Show amount Woocommerce completed orders within a specific months
I would like to have a view of the amount of orders that where put to a completed state within the last months. I do not need very much details but just a very simple list with two columns.
"...
0
votes
1
answer
20
views
React JS Class Component - Set Sate
I'm just trying to update the state of totalItems and total price. I've created the logic within the cart class component below but I'm receiving the following errors:
Cart.js:24 Uncaught TypeError: ...
0
votes
0
answers
27
views
PageView : Jump to page 3 without calling init state of page 2 (Flutter)
I am using a PageView widget with a PageController.
I am well jumping from page 1 to page 3, but it is calling the init state of page 2. How to avoid that ?
pageController.jumpToPage(2); // jumping to ...
0
votes
1
answer
30
views
DispatchQueue.main and thread safety
Consider the following toy example
import SwiftUI
struct WeirdExample: View {
@State private var greetings = ["Hello", "Bye"]
@State private var count = 0
@State ...
0
votes
0
answers
19
views
How to set default value in multiselect dropdown in multistep form with react-select
I am currently working on a multistep form with multiselect dropdowns with react-select. Everything works so far, except when switching between steps, the dropdown fields are not filled with the ...
0
votes
1
answer
29
views
Is it bad practice to have parameters the same name as a variable in the outer scope?
I've run into this enough that I thought I'd ask: is it bad to have parameters the same name as a variable in the outer scope. This happens alot when I write in React or Svelte where the state of the ...
-2
votes
0
answers
19
views
react state get spesific object from array with state to another componente
i am new to react and i need to learn a few things
i need to know if my way to get spesific movie is correct (its working but i think its not the right way)
i have a state of data
i need to get ...
0
votes
3
answers
25
views
React JS - Error when using this. state next to the component
I am receiving the following errors:
1.Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: array.
Check your code ...
0
votes
1
answer
18
views
Python Aiogram: Convert 'State' to 'int'
Let's say I want:
A bot to ask how many doughnuts the user needs, and in response it receives the word "doughnuts" multiplied by the number entered by the user.
Simple example:
Bot: How many ...
0
votes
1
answer
21
views
Flink defaults to Kryo serialization even for POJOs and Avro SpecificRecords
I am trying to do a POC of Flink State Schema Evolution. I am using Flink 1.15.0 and Java 11.
I tried to create 3 data classes - one for each serialization type:
io.peleg.kryo.User - Uses java.time....
1
vote
1
answer
21
views
eventInfo.currentTarget.value crashes inside React callback but not in event handler?
I'm using React (18.2.0) and I'm trying to create a page where I enter text into a textbox, and the page immediately updates on-page elements using that new text. The minimum example looks like this:
...
0
votes
1
answer
33
views
How do i set a specific value of an array of an array of arrays within the state
In the following code, editableRowData an array containing an IComponent[] object (components):
deleteComponent(index) {
...
this.setState(prevState => ({
editableRowData: {
...
0
votes
1
answer
30
views
Changing login state don't change items on drawer with react-navigation
Im really new to react and probably doing something stupid but cant found a working example then posting my question here.
I want change the content of drawer in function of the user have ...
0
votes
1
answer
11
views
React setting state using function not merging like objects
This function is called whenever MUI's data grid pro column width has been changed. I am trying to capture the "field" and "width" from the "params" and create an array ...
0
votes
0
answers
22
views
In SQLite, do attached databases take on, or inherit, the pragma settings of the main database?
In SQLite, do attached databases take on or inherit the "pragmatizations" of the "main" database? Or must I "pragmatize" each database, after an "ATTACH" ...
0
votes
1
answer
25
views
How to export a state in react native, and import it into another file? (NOT COMPONENT)
I am trying to export this state: const [jsonText, setJSONText] = useState(); out of my file. I tried a simple export const jsonText;, but that did not work at all. I tried looking it up, but they ...
2
votes
1
answer
34
views
How to handle redirect from identity provider in OpenID Connect flow in SPA without losing state
I'm trying to implement social login functionality in a MERN SPA so that users can login to my site using their Google/Facebook/Twitter/etc. login. This is clearly a very common scenario, and there ...
0
votes
0
answers
9
views
Render not waiting for componentdidmount function
I have a componentDidMount function which checks wether the user is logged or not by calling an API
This is my summed up code layout:
state = {
login: false
};
componentDidMount() {
...
0
votes
2
answers
26
views
What is the best approach to reset state array of object in react js
I am trying to reset an array of object but I am unable to do it without rewriting the initial value of the state again.
Initial state
const [state,setState]=useState([
{name:'abc',age:24},
{name:'...
1
vote
1
answer
27
views
values.map is not a function n reactjs while passing array in state and mapping the current state
I have passed an array of objects in useState hook as the initial state and i want to iterate over it using map method in other component, i have passed the current state as prop in the other object ...
0
votes
0
answers
14
views
setInterval won't able to catch up the state change inside setInterval? [duplicate]
const handleAutoPlay = () => {
const attackInterval = setInterval(() => {
if (playerOne.hp <= 0 || playerTwo.hp <= 0) {
clearInterval(attackInterval);
}
...
0
votes
0
answers
12
views
State only updates last value in array? [duplicate]
I have an issue with my image uploader. I'm trying to create a feature where a user can upload 1 or more images and then have them displayed before they're uploaded. The code works when only 1 image ...
0
votes
0
answers
11
views
How to update a view in fragment not in "Compose" by observing Stateflow object that Contains my data?
I have a fragment that contains a current user data like firstName, lastName and address
class EditUserFragment :Fragment() {
val viewModel: EditUserAddressViewModel by viewModels()
...
@...
0
votes
1
answer
51
views
React: Child don't update parent's state
I'm new to React and I was trying to create a Modal using mui that opens and closes based on parent's state.
The problem is that the modal opens well based on state but upon closing, the modal onClose ...
0
votes
4
answers
48
views
How to handle a complicated state in react
Background: I am kind of new to react and am learning it, I have made some sites in it but i Highly doubt my way of appraching the problem.
So while handaling a complex state .
For example lets say we ...
-1
votes
0
answers
25
views
how can render the array present in state in html using map function by using function component?
**how can render the array present in state in html using map function by using function component ? **
I am trying to render the table of a given number by user and every thing working but i am ...
0
votes
0
answers
44
views
Understanding UI State : Dynamic TextInput loses focus after each key press
Screens and navigating is fine, but getting data from users has been a struggle. Not only are the UI elements different, the means to capture input and store in state effectively across various input ...
0
votes
2
answers
40
views
How to put a svg :before state
I want to put a svg before a div element in Oxy, I tried it with css but I failed because I am still learning css.
I hope the image makes sense. I want to put the SVG where the arrow points to svg.
...
1
vote
1
answer
24
views
How do I make sure that the parent state is also updated when child state is updated?
I have a architecture of a React application as follows:
<GrandParentComponent>
<ParentComponent>
<ChildComponent>
</ParentComponent>
</GrandParentComponent&...
2
votes
2
answers
42
views
How to access values of state in other function
How can I use the value of state x in handleClick function to show an alert of input value in state x using Function component?
import React, { useState } from "react";
import "./App....
0
votes
1
answer
20
views
How to prevent date variable from being updated on re-render
I'm making a timetable grid, of sorts. It looks something like this
Here's the state and helper functions for getting the data:
const [currentDate, setCurrentDate] = useState(new Date());
const [...
0
votes
2
answers
20
views
Difficulty updating state onChange in a Select tag React
I have a simple app to Generate a Random color. But it only updates on the next change and I can't figure out how to get an updater function to work.
const handleHueChange = (e) => {
const ...
1
vote
3
answers
20
views
react forms Controlled component
I am trying to make a form where inputs fields can be generated dynamically. While running it runs but react throws a warning about not being a controlled component. Any example for the solution I ...
0
votes
1
answer
18
views
react state not updating properly for file uploader
I am trying to make a drag and drop feature with some files. I want to make it so that when a user drags and drops multiple files, those files are all added to a list. However, only one of the files ...
0
votes
1
answer
40
views
React Class Component - This.Set.State
I'm trying to complete this countdown timer using a class component in REACT. I believe I'm just missing "this.Setstate" adding . Can you please review and let me know where that would be ...
0
votes
0
answers
19
views
State is updating but not being sent to DB.json - REACT
Ok so here's the repo: https://github.com/bigolboyyo/phase2final/tree/projectbranch5
I'm in a boot camp and working on a live chat app. For some reason even though state is being (assumingly) updated ...
0
votes
2
answers
40
views
React Context State Update
I need help updating a user within various parts of my react app.
I have successfully been able to create a context and access it globally, but anytime I try to update the state, it either breaks or ...
0
votes
1
answer
17
views
How do I make the API rerender and update the component when the search field is updated in React?
I have a page in my React Gatsby project where I retrieve data from an API and the page renders the details from the API.
I am trying to add a search feature where the API re-renders when the input ...
-1
votes
1
answer
51
views
React button not clickable
Hi everyone I'm building a simple waitlist page in React. In the Hero section, i've created a heading with an H1 and a form. The input form is working perfectly, the css is being activated when I ...
0
votes
1
answer
24
views
Font awesome class icons toggling not working Vue
So I am working on the signup form using Vue.js and there is this password part that I want the user to view password and toggle back to unseen password I have both font awesome icons (fas fa-eye and ...
1
vote
1
answer
45
views
How to add color in some specific words in a text React JS?
I am developing a text area that contains some specific words(Eg. they can start/end with "%": %QWERTY%). I want these words to have a different color(E.g: Green) and the text area is still ...
0
votes
1
answer
31
views
Use a global state with Context
I'm currently trying to set a globalstate into my app. It's just about counting points, so a global "score".
Context seemed easy and I followed some tutorials, but it keeps sending errors.
...
2
votes
1
answer
44
views
"requestCursorUpdates is not supported" error with OutlinedTextField
I have several OutlinedTextField inputs, and typing into them does nothing while using a Data Class as the state holder in the ViewModel. Logcat returns the following Debug error each time I type a ...
0
votes
1
answer
41
views
I can't fill a request response using axios in state variable in React.js with Next.js
I'm working with React.js and I have the following problem:
import axios from "axios";
export default function Home() {
const [products, setProducts] = useState([]);
const ax = ...
0
votes
0
answers
23
views
states problem using redux inside the reducer, how to identify where to give what state
I have been learning redux and using in my application i love it but one thing face as big problem is state of reducer
Usually when i have to get data from data base and if it happens to be in array i ...
0
votes
2
answers
31
views
React - setting value for all array of objects
I'm creating a simple tracker that has a state checking if the button is either false (not checked) or true (checked).
The structure of my data is something like this:
const [test, setTest] = useState(...
0
votes
0
answers
36
views
i wanted to get data from local storage and map it into table but i am not getting any data from it in ReactJs
this is users component i want to pass the local storage data to view and i am not sure how can i do that
const [formValues, setFormValues] = useState([]);
useEffect(() => {
const formValues =...
1
vote
1
answer
46
views
Java - State pattern: Using threads within the states
I want to coordinate serial requests coming from a Java Swing GUI using the state pattern. When a state method was called, the serial communication shall start and in parrallel the GUI should not be ...
1
vote
1
answer
43
views
Cannot update the state of an object within the state (react)
I have an object variable within the state of my react app. I initialize it with the structure that I want the object to have. Late I am trying to update that object using the setState function. My ...