Don’t know what I’m doing wrong here. I am trying to create a function in React to iterate over a string you pass through, then add an animation class to each element, while also upping the animation delay by .1s every letter. This is what I have currently and am unable to add the class as it comes back with undefined??
Confused by this. I don’t know what you mean outside of React. I’m trying to map currently and maybe to a string interpolation on the delay like so, but delay is undefined:
There isn’t any point in useAnimationClass being a function, you look like you’re overabstracting here
Simplest way here is make a component that takes an array of letters and returns a mapping to a span for each. Then set style={{animationDelay: whateverTheDelayIs * index}} on each span
Nono, don’t think that – there are specific patterns to use when coding React apps that make life easier. But it’s easy to code yourself into a hole when you get an idea stuck in your head and you think you know how it should work and then completely bypass those patterns or forget about them
No problem! Just keep in mind that wrapping each letter of the string in animated span is quite a heavy load for browser. It’s absolutely fine if it’s the only element on the page, like splash screen or something, but if page has a lot of stuff it might be overkill