DEV Community

Discussion on: Recreating the material design ripple effect in React

Collapse
 
sannajammeh5 profile image
Sanna Jammeh • Edited

Solid guide, however there is a mistake in your code! You are setting the rippleArray with newRippleArray which is an Object. Therefore the map method is never called. You must change setRippleArray(newRipple) to setRippleArray(prevState => [...prevState, newRipple]);

Also debouncer callback is never called because you immediately return the clearTimeout, not a function that calls clearTimeout.

Change useLayoutEffect(fn..., return clearTimeout(bounce), [...]); to useLayoutEffect(fn..., return () => clearTimeout(bounce), [...];

Collapse
 
rohanfaiyazkhan profile image
Rohan Faiyaz Khan

Thank you so much for catching that. Fixed it.