2,651 questions
0
votes
2
answers
60
views
How do I pass an updated object down to a Child Component in React?
I have this code where I've updated an object in React. When you click "Most upvoted", it takes an object, sorts it by votes, and then updates the state with it. The problem is, it won't ...
0
votes
0
answers
58
views
Unable to rebuild widget because provider's consumer does not trigger rebuild down the widget tree. How to solve this?
My Goal: In the following minimal code, I have MyMainInputWidget and YearInputWidget as input capturing widgets which are required. I don't want to call any provider methods within the YearInputWidget ...
0
votes
2
answers
110
views
Flutter setState Not Rebuilding DropdownSearch with Lazy Loading
I am using DropdownSearch with lazy loading inside a modal bottom sheet in Flutter. The list of items is fetched using Bloc (LocationMasterCubit), and I am handling infinite scrolling to load more ...
1
vote
0
answers
30
views
My show/hide sidebar button update my state variable in my flutter desktop app
I'm having a weird performance about how onPressed function of my button to show and hide a sidebar is working.
I have a stateful widget with a PageController to manage the pages when I click in my ...
1
vote
1
answer
47
views
When do I call setState to re-build the widget tree with values obtained from an asynchronous call?
I have a UI that uses http to get data from CoinApi.io. This async call populates a map that is in turn used to update the SliverGrid. This is based on a currency selection from a Cupertino app. What ...
0
votes
0
answers
33
views
how to update single widget in flutter [duplicate]
Currently, my screen is a column has multi widget like this:
Column(
children: [
FutureBuilder(future: ft1, builder: builder),
FutureBuilder(future: ft2, builder: builder),
...
2
votes
1
answer
66
views
React setState of the last object in the array state
i have array of objects state that hold users objects, when user clicks add button it adds a new empty object to the state
setUsers([...users, newRow]);
when user upload image i want to add the image ...
0
votes
0
answers
52
views
request focus not working after few time with setState Flutter
here is my code
late FocusNode fcMa, fcViTri;
@override
void initState() {
super.initState();
fcMa = FocusNode();
fcViTri = FocusNode();
fcMa.requestFocus();
}
@override
...
0
votes
3
answers
51
views
Not possible to increment the counter using set state in a simple recursive function in React
I understand that setState is asynchronous, but does it explicitly wait for all other code to be executed before it completes (even setTimeout with delay)?
I've been trying to increment a counter ...
1
vote
2
answers
286
views
When does setState trigger a re-build?
I am not sure exactly when setState triggers the rebuild in Flutter.
I have some text on a screen that I update with setState. It rebuilds nicely. Here is the code:
setState(() {
futureWait = "$...
-1
votes
2
answers
55
views
set state function in the custom_dialog doesn't work
setState function in the custom_dialog page dosen't work
in this code, I want to show a list of customers with a specific data for each customer. The issue is when I want to add a new customer through ...
0
votes
1
answer
32
views
Before function flow is not finished yet and setState update is not done, get latest state for debugging purpose
Is there any chance to see updated state before function flow is not finished in React for debugging purpose.
function a = () => {
....statements
setState(a);
....statements
{here can I ...
1
vote
1
answer
47
views
react setState mistake
have a mistake in a articles.js
articles.js:
import React, {Component} from 'react';
import './index.css';
export default class Class extends Component {
constructor(props) {
super(props)...
0
votes
1
answer
104
views
Flutter Pagination & Provider: setState() or markNeedsBuild() called during build in NotificationListener
I am currently building a GridView for an image gallery in Flutter, utilizing a provider to manage my media list and to integrate a caching system. The GridView is designed to work with pagination, ...
0
votes
0
answers
82
views
Why is set state so slow here?
I have a custom chart with clickable points. After a point is clicked I want to change another component which shows that days commits to show the date of the point being clicked. In the parent ...
0
votes
0
answers
34
views
React: `setSomeState([..., x, ...])` update only applies to particular child element
Sometimes I want a parent element to keep track of the children's state. For example, a state that's a list where each item corresponds to exactly one DOM-child. In my application this is a multi-...
-1
votes
1
answer
37
views
reactjs - useEffect not getting updated value of state variable?
I am having an issue where everything inside my useEffect call does not seem to be getting updated state variables.
Before updating my state variable bboHistory with setBBOHistory, I print prev and I ...
-1
votes
2
answers
43
views
i have bottom sheet for comments section; setState(() {}); not updating until any other action
one thing you have to keep in mind. i have create this class in external file and executing sheet from main code because same sheet needed in many of screens. so for showing sheet perfectly first i ...
0
votes
1
answer
70
views
How can I use the onClick functionality of one component inside another component in React?
I am creating a whatsapp clone.
For showing profile picture, I have made a card component which is accessed from a top_bar component.
function Show_dp(prop){
return(
<div id="box&...
1
vote
2
answers
80
views
Why is my setstate function causing other functions to malfunction in react.js?
const [lap, setLap] = useState([]);
function start(){
if(!isStart){
starting = Date.now() - elapsed;
isStart = true;
timer = setInterval(update, 1000);
...
-1
votes
1
answer
41
views
setState not triggering a re-render when data has been modified(state type is variable)
I changed a state with setState, but it did not trigger a re-render. I considered it a minor issue, so I searched extensively, but I couldn't find a solution.
I want to check the second and third ...
0
votes
0
answers
52
views
How can I call a setter function inside of setState
I have the following class:
export default class Global {
public config!: Config;
public components!: Component[];
constructor(config: Config) {
if (!config) {
throw new Error("...
0
votes
1
answer
34
views
async setState in react not effect
I have a app.jsx, which will request two different api named API_A & API_B. I will get data_A and data_B from this two api and merge them into a info state for render ui. My code is like this:
...
0
votes
1
answer
49
views
'onTap' isn't working, After fixing the "setState() or markNeedsBuild() called during build." error
I am building the BMI calculator app,
after all, it giving me "setState() or markNeedsBuild() called during build." error.
so, i come up with below solution..
onTap: () {
...
2
votes
3
answers
298
views
ReactSearchAutocomplete - set state not updating items, only updates on next search
I'm using ReactSearchAutocomplete to display a list of 10 suggested names from a mySql query. The query is performed with a 100ms delay on user input, and it works fine but I'm clearly not handling ...
1
vote
1
answer
498
views
Is it possible to update state within a useReducer
So here's my issue, im currently learning about the useReducer function and trying to utilize it to create a react based quiz, selection screen. I wanted to update the state (so it could be uplifted ...
1
vote
1
answer
59
views
Wrapping setState in NavLink callback gives bad setState warning
I have a Tabs component that has bunch of NavLinks. I'm trying to show a loading spinner based on the NavLink's isPending property on the parent component. So I'm showing spinner when there is a ...
0
votes
2
answers
53
views
How can I rebuild a widget after the StreamBuilder gets built?
I'm trying to get the totalValue in the title of the appBar. The value of totalValue comes from the Streambuilder and it changes everytime I press the FilterChips.
Code:
import 'package:flutter/...
0
votes
1
answer
42
views
React setState from fetch and send it to another fetch
I have a function that calls 2 functions, one uploads an image and stores it in some directory, and the other send product related data to edit/store in the database:
const uploadImage = async () =&...
0
votes
1
answer
54
views
Disabling Flutter ElevatedButton is not fast enough
I have followed the examples on disabling the flutter elevatedbutton after first press, but its not fast enough. Part of my onPressed makes a call to a backend server for data, but its somewhat of a ...
0
votes
1
answer
379
views
Infinite Loop with Excalidraw and React Using Basic setState?
I'm trying out some very basic way of tracking the Excalidraw (0.17.5) elements in React, but I'm getting something like stack overflow. Why???
import { useState } from "react"
import { ...
0
votes
1
answer
71
views
Default value of input 2 is from input 1. Why does the state of input 2 not get its default value from input 1?
I have 2 <input type="text"> elements. What users type in input 1 will be the default value of input 2. The value of input 2 will be used for other tasks. The tasks should run right ...
-1
votes
1
answer
66
views
React setState not rerendering
Started a course on ReactJS and on Chapter 4 I encountered this issue. I have verified with several posts and none work. setState() is any implementation has not re rendered the component.
const ...
0
votes
1
answer
55
views
Dropdown Values not change in Flutter Modal
I have this Dropdown Widget in a Modal and I cannot Change the Value in the Widget while I'm using setState and everytime I change the value, I should close the Modal and then the Value is Changed.
...
0
votes
0
answers
260
views
Using set state from a dialog box with StatefulBuilder in flutter
I am trying to make a simple social media app and I am using a alert dialog for the user to add a new post. Im trying to update the alert dialog using statefulBuilder when I add an image but the image ...
-1
votes
1
answer
34
views
React setState changes the value of all objects in different state variable
Here's my code:
import "./styles.css";
import { useState } from "react";
export default function App() {
const [input, setInput] = useState("")
const [list, setList] =...
0
votes
1
answer
61
views
SOLVED! setState() or markNeedsBuild() called during build ,stuck on this although the app work normally
This is my home screen and it is working fine but it is throwing error each time I navigate to it.
I don't know what to do , all of the app is working normally , it is just throwing this errors and I ...
0
votes
2
answers
78
views
How to call setState in an app wide function?
I have a an app-wide file that has several functions that are used several places in the application. In one of those functions I want to call setState. This causes an issue because the function is ...
0
votes
2
answers
77
views
I cannot display a changing value on the screen in my flutter application
I uploaded 3 pages of related code here. My problem is this: I press the Pick Country button and select a country, but I can't display my screen the phoneCode parameter of the country I selected.
I'm ...
0
votes
1
answer
44
views
React response from fetch as json
The fetch statement getting json data from the server. I want to get the value of the object to be saved in state. The response is only one element in it [{"QuestId":1700}]. How to get the ...
3
votes
1
answer
1k
views
Flutter FutureBuilder keeps Firing and rebuilding. It Generates a New Random Number on Every Rebuild - How can I Prevent This?
Context
I am encountering an issue with FutureBuilder in Flutter where it recreates its Future on every widget rebuild, causing unexpected behavior in my app.
Specifically, I have a FutureBuilder that ...
0
votes
1
answer
428
views
Best approach to get the current state value
I want to know what's the best approach to get the current state value.
I figured out 2 options to reach the current value instead of getting stale value by whether using useEffect hook or using the ...
2
votes
2
answers
550
views
Why does Flutter PageView resets to page 0 after setState
Above the first Page that shows, I show a message that the user can swipe left to go to the next page. In onPageChanged I set a bool to dismiss the message and call setState. When I swipe to page 1, ...
6
votes
2
answers
2k
views
How to rebuild a suggestionsBuilder from SearchAnchor manually?
I want to use the SearchAnchor Widget, but unfortunately, I find no way to trigger a rebuild. I have tried many approaches to achieve something similar to what is shown in my picture checklist inside ...
4
votes
2
answers
359
views
react's useState does not sets new state
I have the following frontend:
AuthContext.js:
const { createContext, useState, useContext } = require("react");
const AuthContext = createContext();
export function useAuth() {
return ...
-2
votes
1
answer
90
views
When using useEffect (with an enclosed setState and a fetch), are there any issues to be be aware of when using async/await vs Chaining .then?(NextJS)
Please note - this is NOT a generic Javascript question about async/await vs. .then. If you are curious about that, please look here: Difference of using async / await vs promises?.
This is a ...
0
votes
0
answers
30
views
useEffect render previous value, instead new setState
Im trying to set set an IP address into "" and (last queried value).
But its always render same state and render new state after second render.
I know its because of setState syncronomous ...
0
votes
1
answer
37
views
How to loop over a const object in ReactJS
I have a const in ReactJS which is an object and I want to loops over it to set all values to undefined to reset the state and re-render the component to get a clean form
const [newPayee, setNewPayee] ...
1
vote
2
answers
324
views
Flutter Not Calling Build in a Widget After setState() Despite a Change in State
I have called setState() to update the objects of the class MyErrorBox, but Flutter does not run the build function for those objects. I am new to Flutter and coding in general. The MyText class in ...
-1
votes
1
answer
57
views
react setValues hook is not working properly
I have an array of files that will be uploading, but I want to change the array of file strings to an array of objects which is working fine. But when I try to update the variable to the new array, it ...