Category "use-effect"

How to resolve act() in useEffect?

I have a small problem with act() error in react-testing-library. In useEffect I try to call an function that is a promise. Promise returns some data and displa

filter operator explained step by step

function deleteTask(id) { const remainingTasks = tasks.filter((task) => id !== task.id); setTasks(remainingTasks); } Ijust want to know in plain english, as

TypeError: func.apply is not a function

I'm trying to use useEffect function like that: const [data, setData] = useState({ courses: [] }); useEffect(async () => { const result

Can a React usestate update be nested in another useState functional update?

There are n items the user can vote on. There are two React states: votes is an array of the user's votes on every item. const [votes, setVotes] = useState({});

React Redux state is not being updated when using useSelector inside useEffect

I'm new to react and when I'm updating my state in redux, I'm no able to see my state updated in my component inside a setInterval, despite the state in redux i

Accessing and updating canvas node callback inside of useEffect - React

I've created a canvas which is set to a state using a callback. circles are then created based on mouse x and y that are then drawn to the canvas state after cl

setState inside useEffect doesnt update UI

i am trying to fetch multiple endpoints in UseEffect and depending on it's result show data on the UI (avatar, username, etc.) Problem is, that the data receive

context.putImageData() Not working in React

Im trying to create a drawing application in react, its working for the most part. But when i try add an undo button it doesnt work. I try make the undo button

Infinite loop with a useEffect in React native [duplicate]

I have a problem, on the two functions below, when I check the debug of my request, there is an infinite loop of my GET request and I don't un

Why my nextjs component is rendering twice?

This is a component that render data from firebase storage and make it listed. What the function has to do is set the videos extracted from firebase storage to

Why is localStorage getting cleared whenever I refresh the page?

Like the title says, the localStorage I set registers the changes made to the todoList array and JSON.stringifys it; however, whenever I refresh the page the ar

Compare value inside of use-deep-compare-effect

This is a part of use-deep-compare-effect source code export function useDeepCompareMemoize<T>(value: T) { const ref = React.useRef<T>(value) co

get value when updated,outside of formik using useRef()

I'm trying to get the value of an autocomplete field outside of my formik component everytime it changes, and i did something like this: const formRef=useRef<

How to avoid warning: Outer scope values like 'userDTO' aren't valid dependencies because mutating them doesn't re-render the component

getTransactions method call need to be called only if user is logged in, but the info about the user will not be visible. What can I do to force a reload when o

Axios get request not performing correctly after useEffect cleanup

I am writing an axios get call useEffect that is called whenever a user selects an option from a dropdown menu. It works on getting info on the first time I sel

use Effect is repeating lottie animation

Learning React here, and I'm simply trying to display a lottie animation. Seems fairly straight-forward, but I'm having some trouble with the useEffect hook.

How to update a form's input text state immediately in React using setState()

const [text, setText] = useState(''); const handleTextChange = (e) => { setText(e.target.value); } // Inside a form <input onChange={handleTextChange