Skip to content

Tag: reactjs

why does setState runs once inside the map?

I have an array of objects which I want to map it and set the objects into the messagesList state, but only the last object is set. Actually, I want the setting to be done as soon as the map is executed but here it is done only once and the last item of the array is set. You can

Spread objects into a state array

I am trying to spread values as objects into a state array in react, but this code causes this error: Error: TypeError: Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method. Is there a chance I can spread values from the data array …

Date.getTime() in Next.js returns weird numbers

I am trying to make a page transition in Next.js. As the transition is slower than the page load, I need to calculate the missing time for the animation to finish. The transition should last at least 2 seconds, 1s for a fade in of the loading screen, 500ms so that the loading screen stays a little, and 500ms …