Skip to content

Instantly share code, notes, and snippets.

@frivas
Created May 25, 2022 18:55
Show Gist options
  • Save frivas/fbc04fe8378a1fbabcb2e9a0b50a3bd5 to your computer and use it in GitHub Desktop.
Save frivas/fbc04fe8378a1fbabcb2e9a0b50a3bd5 to your computer and use it in GitHub Desktop.
Chapter 06 - 6.2.3
function BlinkingBackground() {
const [isLeft, setLeft] = useState(true);
console.log(isLeft);
const onMouseMove = (evt) => {
return setLeft(evt.nativeEvent.offsetX < 90);
};
const divStyle = {
backgroundColor: isLeft ? "blue" : "red",
width: "100px",
height: "100px"
};
return <div style={divStyle} onMouseOver={onMouseMove} />;
}
export default BlinkingBackground;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment