Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save florianmartens/3b08d9eb654623829c8850779bce3b17 to your computer and use it in GitHub Desktop.
Save florianmartens/3b08d9eb654623829c8850779bce3b17 to your computer and use it in GitHub Desktop.
import "./styles.css";
import { useState, useEffect } from "react";
export default function App() {
const initalState = 0;
const [count, setCount] = useState(initalState);
useEffect(() => {
setInterval(() => {
setCount(old => old + 1);
}, 1000);
}, []);
return (
<div className="App">
<h1>The current count is:</h1>
<h2>{count}</h2>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment