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

I think i have done something that's setstate is not working in flutter

I am pretty new to this field so please go easy on me. I am learning flutter I have made a card in my app and give it a delete button but the button is not deleting any of the card. please help me out. here is my code. import…
Shayan Ali
  • 13
  • 1
  • 3
0
votes
0 answers

fetch Weather and Time Data - openweathermap - update Data

I want to update the time every minute without refreshing the whole page. This is a part from the code which I used from github: const fetchData = async () => { setIsLoading(true); try { const forecastResponse = await axios.get(endpoint, { params…
0
votes
1 answer

Pass counter component value to it's parent component

I have a simple counter child Component. import React, {useState} from 'react' import classes from './counter.module.css' const Counter = (props) => { const [number, setNumber] = useState(0); const decrementHandler = () => { …
Rejin Jose
  • 41
  • 6
0
votes
1 answer

What does mount mean in Flutter ? why is it used?

void initUser() async { currentUser = await UserController.getUser(); if (mounted) { setState(() => 0); } } What is this code doing? I've read the documentation but still couldn't understand. What is this mounted keyword and…
Milan Poudel
  • 602
  • 1
  • 9
  • 20
0
votes
1 answer

onTap method not able to change the Color of the Container inside Stack and opacity of the Color of card inside Animated container

The setState method inside stack does not change the value of Color Widget and opacity value inside a Stack. I want to change the green color of the container to red when the flatbutton -> "change color" is tapped to red, but no change appears.…
Manan Jain
  • 43
  • 1
  • 5
0
votes
1 answer

Change Password in firebase with react native

Im trying to update the password in the database firebase with react native It works but I have the error "The password must be 6characters long or more" I know this is because of the "this.setState({newPassword: "",currentPassword: ""})", but I…
user123456
  • 171
  • 11
0
votes
1 answer

trouble using set state correctly to update an event in react Big Calender

I am trying to implement react big calendar however I am having an issue with adding an event and using set state to update the event.I created a my calendar component then use the handle select function to take the new event and set the state but…
Los
  • 3
  • 2
0
votes
0 answers

React SetState returns [Object Object] even though api returns valid json

Fetch is successful in below code (I have confirmed by looking at console - Network in browser) but the setState is not updating the allWeights array in state with the array of documents from MongoDB returned by API. When I use console.log() it…
0
votes
1 answer

React Native - type NSString cannot be converted to a ABI41_0_YGValue

I am trying to fetch data from a JSON file and calculate a value, I saved the value using setState and I want to use it as the height of a React Native component (touchable opacity). I did managed to get the values however when I try to run the…
cel-0207
  • 31
  • 7
0
votes
2 answers

Why do I need to add .isToggleOn?

In React Docs, handling events article: how state is being updated to the opposite boolean value, I have a question. Why do we need to add .isToggleOn after isToggleOn: !prevState Why can't I just simply write isToggleOn: !prevState? prevState is…
J L
  • 13
  • 2
0
votes
3 answers

setState() or markNeedsBuild() called when widget tree was locked

Flutter i am trying to display a widget into Stack IF an condition (true or false ) , and it work with no problems but when i need to change the condition bool into SetState to hide the Widget again , it is also work but with annoying error messages…
Jack
  • 161
  • 1
  • 16
0
votes
1 answer

Can not set initial data to child component because it is undefined on page load

I have 5 cities and their weather displayed on a card on page load, when you click a city I want more details to appear on another card but the detailed card needs to have initial data of the first city from the first card but I can't seem to get it…
zer0day
  • 236
  • 1
  • 3
  • 11
0
votes
3 answers

useContext - my parent does not render when i set state in the child

I am not that good at react js.. I just wanted to make a "Global value" to let the childs of that parent see that value so I found useContext that allow sharing values along. so I wanted to use (useState) so I can set it from the child so it…
0
votes
2 answers

state going empty when using useEffect

I have 5 cities and their weather displayed on a card when you click one I want more details to appear on another card. I also want the detailed card to have initial data of the first city. Problem is when I try to set the clicked data to state in…
zer0day
  • 236
  • 1
  • 3
  • 11
0
votes
1 answer

Updating a widget and issue with setStat

I am currently working on this tutorial in which transfers a variable "myVariable" an external file to another. Link: https://dev.to/lucianojung/global-variable-access-in-flutter-3ijm I modified my code so that the variable "myVariable" is usable in…
user5824983
1 2 3
99
100