Ubong Josh
Ubong Josh
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
Ok, that is much better 👌 thanks
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
@ChooKing @Aoi
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
export function Brand({ text, speed }) {
let [currentLength, setCurrentLength] = useState(0);

useEffect(() => {
let interval = setInterval(() => {
setCurrentLength((currentLength) => {
if (currentLength >= text.length) return currentLength;
return currentLength + 1;
});
}, speed);

return () => {
clearInterval(interval);
};
}, [text, speed]);

return <span className='font-bold text-3xl'> {text.slice(0, currentLength)} </span> ;
}
export function Brand({ text, speed }) {
let [currentLength, setCurrentLength] = useState(0);

useEffect(() => {
let interval = setInterval(() => {
setCurrentLength((currentLength) => {
if (currentLength >= text.length) return currentLength;
return currentLength + 1;
});
}, speed);

return () => {
clearInterval(interval);
};
}, [text, speed]);

return <span className='font-bold text-3xl'> {text.slice(0, currentLength)} </span> ;
}
this worked out, thanks a lot
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
I really didn't put it at first.. the underline only went away after I put it Like you said, I need to make some changes to my EsLint settings
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
Ok thanks a lot, I'll keep that in mind
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
Ok I've seen this
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
Sorry, I meant..
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
Is the initial useState not supposed to be 0? , and if when the current length is greater than name length, why not return nothing 🌝 it feels like return 0 would just kickstart the whole loop again I'll check it now, anyways, I'll drop feedback right after
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
I am still learning 😹 if I am to remove it completely I'll have to look up some syntax , or type everything manually which is a stress
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
I'll try this
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
Yes , I did this
24 replies
KPCKevin Powell - Community
Created by Ubong Josh on 6/17/2024 in #front-end
setInterval loops over the first character
EsLint screams at me when I take it out of the dependency, and it doesn't make any difference if it's there or not
24 replies