I tried to use useState to update the video background, but it seems not working.
Here is my code:
const [bgChange, setbgChange] = useState(backgroundDay);
const handleBackground = () => {
bgChange === backgroundDay
? setbgChange(backgroundNight)
: setbgChange(backgroundDay);
console.log(bgChange);
};
return (
<div className="container">
<div className="-z-50 absolute">
<video className="videoTag" autoPlay loop muted>
<source src={bgChange} type="video/mp4" />
</video>
</div>
<button onClick={handleBackground}>Change BG</button>
</div>
);