Check out my code snippet below:
renderSoundWave = () => {
const defaultStyle = {
opacity: 1,
transition: `opacity ${DURATION}ms ease-in-out`,
}
const transitionStyles = {
entering: { opacity: 1 },
entered: { opacity: 0 },
};
return (
<Transition timeout={DURATION} in={this.animate}>
{(state) => (
<div className={styles.soundWaves}
style={{ ...defaultStyle, ...transitionStyles[state]}}> {/* Issue occurs here! */
<SoundWaves/>
</div>
)}
</Transition>
);
}
The goal is to utilize Transition
from the library react-transition-group
for animating the icon SoundWave
.
Despite this intention, an error has surfaced:
Error TS7017: Element implicitly has an 'any' type due to lack of index signature in type '{entering: {opacity: number;}; entered: {opacity: number;};}'.
This error specifically references ...transitionStyles[state]
mentioned above
I'm puzzled by the occurrence of this error. What could be triggering this type mismatch?