Questions tagged [setstate]

0 votes
1 replies
Clicking the button does not work - React
I use a component called "Modal" that I want to make global so I can use it in any other component. Modal will be used in all the components that...
asked 1 month ago
0 votes
0 replies
How to call setState for SharedPreferences inside a BlocBuilder without getting an infinite loop?
I have a StatefulWidget, which needs to retrieve the user's account variable stored in the SharePreferences, to display all of its data in the di...
asked 1 month ago
0 votes
0 replies
Call setState inside a function inside a function
I'm trying to call setState inside a function inside a function. Here is my function. //iohook Idle Functions. setIdleTimeout = (millis) =&g...
asked 1 month ago
0 votes
1 replies
How to push array to state several times in react native SetState?
I would like to push several arrays to the same state(array) like below. constructor(props){ super(props); this.state = { itemsArray1: [],...
asked 1 month ago
0 votes
3 replies
How can I unset an active class on each child component while setting it to active for the clicked child
I am trying to set an active class on child component B while disabling the active class on child component A when I click on B. So far I have t...
0 votes
1 replies
Implementing nested fetch API calls with setInterval for dashboard: fetch()+React+Typesctipt
I am trying to bring up a dashboard page with a react table. I want table to be refreshed every 2 seconds.Also I have two fetch api calls , where...
2 votes
1 replies
How to call a setState with data from props? React Native
I have a component Home that is called after user get in. There are some data in that screen, and in the header I have a icon button that send th...
0 votes
0 replies
class method called by cloned child not triggering setState() on page reload
I have a wrapper-component that renders forms provided as children. The wrapper clones the child elements and passes on its methods as props to...
asked 1 month ago
0 votes
1 replies
How to set state , keep getting TypeError: Cannot read property 'setState' of undefined
Im trying to set the state with the data coming back from the axios get.But I keep getting this error TypeError: Cannot read property 'setState'...
asked 1 month ago
0 votes
0 replies
How to reset father component onclick react
I'm doing a menu with a submenu with React. Clicking on the main menu (Example: CRM) creates the submenu (Example Hijo: Argumentarios) but when c...
asked 1 month ago
0 votes
2 replies
How can I set a state only if there is a condition?
I have a percentage into a text view that changes, but it can't be more than 100%. I use a function with a setstate and I want that if the percen...
asked 1 month ago
0 votes
0 replies
React Native TextInput flickering on setState
I am building a Currency Input component using React Native TextInput. While the user is typing, the requirement is that the text should always b...
asked 2 months ago
0 votes
1 replies
How to disable only selected button onClick inside .map() function of REACT js
I have shopping Application in REACT js. Im displaying all products using .map() function, and also showing "ADD to CART" button infront of each...
1 votes
1 replies
Set state when testing functional component with useState() hook
When I tested class component with enzyme I could do wrapper.setState({}) to set state. How can I do the same now, when I am testing function com...
asked 3 months ago
0 votes
1 replies
React setState object key with conditional event target
I have a problem on setting object keys in state. So below code is a form with title, body, city and country. With the value given by user, I set...
asked 3 months ago
0 votes
1 replies
React setState object key with conditional event target
I have a problem on setting object keys in state. So below code is a form with title, body, city and country. With the value given by user, I set...
asked 3 months ago
0 votes
3 replies
How to set state with spread operators, when using variables for keys?
I have a certain piece of state like: this.state = { receipts: { qwer12r: {color: 'red', size: '20'} qas123e: {color: 'gr...
asked 3 months ago
0 votes
3 replies
How to set state with spread operators, when using variables for keys?
I have a certain piece of state like: this.state = { receipts: { qwer12r: {color: 'red', size: '20'} qas123e: {color: 'gr...
asked 3 months ago
3 votes
1 replies
unable to setState within if statement
Trying to update the react state within if statement. When snapshot returns true -> switch state from true to false. When snapshot returns fa...
1 votes
1 replies
React Native Picker not updating state
I am developing a react native app. in that i am using picker to select item and update a state. M problem is picker is not updating the state b...
asked 3 months ago
0 votes
0 replies
React Functional setState vs object difference
sDoing a React course I faced with a strange situation deleting object from state. The course author used non-functional state update but I tried...
asked 3 months ago
0 votes
1 replies
Passing Variable to setState
I am new to react. In my program, the user is asked to click on a button, and according to that button, the state is changed. This is the render...
asked 3 months ago
0 votes
1 replies
setState is not permanent
I am trying to create a sidemenu which has collapsible options. Below is my code: export default class CRSideMenu extends React.Component {...
asked 2 months ago
1 votes
1 replies
react-native. Reference Error value is not defined
I'm having a problem setting a state in react-native. I can console.log the value just fine but when I call setState() I get Reference error 'tar...
asked 3 months ago
0 votes
2 replies
ReactJS - setState working in a weird way
I am trying to add things to a list, in the form of a state array. However, with my current code, the first item doesn't add itself properly. e...
asked 3 months ago