Questions tagged [setstate]

Use for questions relating to the [setstate] method and component/widget state management in [reactjs] and [flutter].

setState is a component method in and which updates the local component/"widget" state and triggers a re-render of the component based on the new state.

Resources

2626 questions
0
votes
1 answer

Console log displaying values but setState not

import React from 'react'; import { useState, useEffect, useContext } from 'react'; import { auth } from '../../utils/firebase'; import AuthContext from '../../contexts/AuthContext' //Components import Navbar from './Navbar'; function Dashboard()…
0
votes
1 answer

SetState call blocks access to field updated by stream

I am making a barcode scanning functionality. The camera feed is setting _currentImage. // CameraView.dart CameraImage _currentImage; CameraImage takePhoto() => _currentImage; void imageStream(CameraImage image) async { …
lolelo
  • 698
  • 6
  • 18
0
votes
1 answer

Not able to set initial values and onchange of input elelements in DataTable React Js

I have a dataset coming down from Parent component to child component(DataTable). I am creating a datatable with the incoming data. I am able to create DataTable but I am facing 2 issues: I am not able write inside the input elements of Datatable I…
Yesha
  • 648
  • 1
  • 7
  • 29
0
votes
2 answers

Switch/Checkbox not updating on setState()

I've been doing this for 4 days, reading half of the Google and watching 3/4 of Youtube. I have a list of objects, I'm getting data from API. When those objects get generated into cards, Switch of Checkbox are not functiona, setState does not affect…
0
votes
1 answer

modal update has delay to set new State in react hook

I have some problem with updating the editModal (react bootstrap modal). after dispatching the action it works and I'm able to fetch single pet data as an object. and redux dev tools confirms that But modal doesn't open at first attempt and I need…
0
votes
2 answers

Refresh listview builder with deleting an element

I have a simple ListView.builder which create each item in its own widget the parent, stateful (using a futureBuilder) : child: ListView.builder( itemCount: snapshot.data.length, itemBuilder: (context, index) { Conversation conversation =…
morganXap
  • 35
  • 6
0
votes
2 answers

Showing data from state variable in ReactJS forms infinite loop

I'm trying to show data from an API call. The structure of the application looks like MainComponent -> RefreshButton (this will fetch the data) MainComponent -> ShowData (this will show the data that is being fetched) MainComponent has a state…
0
votes
2 answers

Flutter how to invoke initState() properly

Hi IM trying to load initial data from db and sharepref as user first open page. ... List questionsList = []; bool _languageA = false; @override void initState() { super.initState(); loadData(); // seting for some dropdown menu …
Alex Apps
  • 317
  • 6
  • 19
0
votes
2 answers

Useeffect not update after i select new item on Select option

I changed option but useeffect not update input. Please guide me where i make mistake. First i use useEffect to setCurrency after that i use mapping for getCurrency to add it on Select option. onCitySelect i added it to setSelectedId when i change…
rubiest
  • 3
  • 3
0
votes
1 answer

Flutter Update Text Widget Variable without Reloading

Im using Flutter with Firestore to make Investing Application. enter image description here In this page, I get Firestore's data in Streambuilder. The data what i recieved are displayed in Listview with Inkwell. What I want to do is when I click the…
0
votes
1 answer

simultaneous updates of React in React

Is it possible to update one state in React and in the same render, can we use the updated value to update another state? import "./styles.css"; import {useState} from 'react'; export default function App() { const [num, setNum] = useState(0) …
0
votes
1 answer

Validating variable to be used in setState

I have a split date input (3 different inputs for DD/MM/YYYY) - I've been having some console issues whereby "A component is changing an uncontrolled input to be controlled - likely caused by value changing from undefined to defined." Basically what…
cts
  • 908
  • 1
  • 9
  • 30
0
votes
0 answers

setState is not updating the value of input when blank

I've got a split date component (with 3 seperate inputs for day, month & year) - the component looked like so: const DateInput = ({ name, onValueChange, dateInputValue }: Props) => { const [day, setDay] = useState(""); const [month, setMonth] =…
cts
  • 908
  • 1
  • 9
  • 30
0
votes
1 answer

Flutter - How do I change a value straight after I setState

I have a bool fetchNew. It's initialized as false and I have a function refresh() that sets it to true. How do I set it to false right after setState preventing the rerender? class _DashboardState extends State { bool fetchNew =…
0
votes
1 answer

React Hooks: Why isn't setState causing Context.provider to rerender?

CONTEXT I have the following React functional component: export const LocationProvider: React.FC = ({children}) => { const [visLocationData, setVisLocationData] = React.useState({}); const addLocationData =…
DRich
  • 972
  • 1
  • 8
  • 25