I got a problem with a React component that takes as a prop scrollY
:
const Button = ({
scrollY,
}) => {
const [localScrollY, setLocalScrollY] = useState(0);
useEffect(() => {
setLocalScrollY(scrollY);
}, [scrollY]);
console.log(`mt-[${localScrollY}px]`);
return (
<motion.button
className={`top-3 mt-[${scrollY}px] ....`}
>
......
</motion.button>)
I can see the mt
class change in the console when scrolling , yet it does not reflect in the UI.Additionally , the console.log
shows the expected class. Could you please let me know what I might be doing wrong ?
Thank you !