const ref = useRef(null);
const isInView = useInView(ref, { once: true });
<div
ref={ref}
style={{
height: "100vh",
background: isInView ? "blue" : "red",
transition: "1s background",
}}
/>