score:2
Accepted answer
i think you can use settimeout
.
const mymethod= () => {
....
....
settimeout(() => {
setdone(true);
}, 2000); // setdone will be called after 2s
}
Source: stackoverflow.com
Related Query
- React Adding delay to apply a class in the state
- Is it a bad practice to use state in a React component if the data will not change? Should I use a property on the class instead?
- Adding a class base on the route in react router
- In react class component why is the state not being changed in the first instance of button click? But in the second instance it gets updated?
- What can I do to store instances of a class and manage state in the context of a react app
- What is the React way of adding active class and removing others on hover in li elements
- Why is there a delay in my React budget app in calculating a total, updating state with setState and then rendering it to the UI?
- pass boolean state value from parent class to child class when a button is clicked in the parent class in react js so that i can load quizes with bool
- React js access to the state of another class
- Rendering React app does not apply when adding items to an array inside a state
- Apply loading state to the items that are clicked in an array - React
- Adding an element to a react reducer state array, Is doubling the element every append
- How to iterate over an state array in React and conditionally delay the next iteration?
- React component State clears after adding additional query parameters to the URL
- React jsx class is showing the data twice after adding the render pdf session
- React - state doesn't update in class component even though the message printed on the screen changes
- React router doesn't apply NavLink active class if the component has mapStateToProps
- Why formData does not take the data there is in the state and that has been refreshed, there is a delay character ? React
- Animation will not run even after adding animation class to the element via addEventListener in React
- How to make a react class component retain its state after login and change available routes based on the state currently available in the component?
- When calling a method in a react class component from a react functional component, is the state visible?
- React - unable to get the store state to pass in a child class component
- Adding a value to the state array results in replacement of previous value - React hooks
- Why does calling react setState method not mutate the state immediately?
- React – the right way to pass form element state to sibling/parent elements?
- Does React keep the order for state updates?
- How do you inspect a react element's props & state in the console?
- react change class name on state change
- Jest react testing: Check state after delay
- React + Redux - Input onChange is very slow when typing in when the input have a value from the state
More Query from same tag
- Why is 'history' necessary in the Router of React-Router-Dom?
- How do i fix "Error: A column ID (or string accessor) is required!" in Nextjs..........[react-table]
- Use of prop to change the css
- Processing an Object During Fetch Returns 'undefined'
- understanding react props and keys
- useState React Hook set method does not update state immediately in onChange()
- React: Cant call setState on a component that is not yet mounted
- Conditional rendering inputs overlap text
- Unit Test react-router onEnter/onLeave
- Losing a part of my state in Redux Toolkit
- How can i switch Radio Button color on ant design - react?
- How to change style of styled-component dynamically?
- I think render works twice
- new document reference of firestore in reactjs
- How to have an array of objects based routing in react?
- SSE server stops responding after a few attempts
- Nesting async functions with .then()
- Intercepting anchor href on an SVG
- How to override Chrome new tab content with a react component
- Filter is not returning a new array
- react, differences between component create with extend class and simple const = function
- Why is my private route checkup always evaluating to false?
- How can I remove the last comma from a map?
- Why does the class attribute disappear from "h1" element rendered by React?
- Dynamically component doesn't work in React
- How to override the transition of drawer?
- Expected an assignment or function call and instead saw an expression in onClick method
- React SVG not rerendering on attribute update
- Custom reusable react component to show or Hide child elements based on flag
- React: Setting useState() hook clears out input fields?