Skip to content

Tag: use-effect

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 with this finishDrawing() function, where i use getImageData and store it in an array called restore_array then when a Undo button is clicked i try to…

useEffect with many dependencies

I am trying to fetch employees and here is what I am trying to do using useEffect Here I want to achieve 2 goals: fetch adminEmployees if (adminEmployees===’unAuthorized’) then go to loginPage but when doing this as in the code, it creates infinite loop. How can I achieve the desired functionality…

UseState renders me the previous state

I have two inputs that change the text of a P tag at the same time, but the problem is that the render that shows me is always the previous value that was saved. I understand that I have to use a useEffect to render the component again and show the current value, but in the inputs handleChange if or