Home > OS >  React useEffect skipping the second render
React useEffect skipping the second render

Time:09-16

I'm creating a DoS-like typing effect dialogue for my website. I've got the effect running but it seems to skip the second render of the loop.

I've got an effect hook that adds each letter from a string to a new state via an index ref until the index ref equals the length of the string. Here's that (enter image description here

CodePudding user response:

Change this lines in tick():

const char = startingLine.charAt(index.current);
setScreenResponse(prev => `${prev}${char}`);
  • Related