Skip to content

Instantly share code, notes, and snippets.

@borispoehland
Last active January 31, 2021 10:59
Show Gist options
  • Save borispoehland/a1be72ef82788b7cdd72f9b46cdf26ef to your computer and use it in GitHub Desktop.
Save borispoehland/a1be72ef82788b7cdd72f9b46cdf26ef to your computer and use it in GitHub Desktop.
import React, {
useState,
useLayoutEffect
} from 'react';
import ReactDOM from 'react-dom';
const BlinkyRender = () => {
const [value, setValue] = useState(0);
useLayoutEffect(() => {
if (value === 0) {
setValue(10 + Math.random() * 200);
}
}, [value]);
console.log('render', value);
return (
<div onClick={() => setValue(0)}>
value: {value}
</div>
);
};
ReactDOM.render(
<BlinkyRender />,
document.querySelector('#root')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment