Last active
February 29, 2024 10:53
-
-
Save AlbertProfe/831fbe700392b9502c77b207d1c54d78 to your computer and use it in GitHub Desktop.
render cycle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
export default function Counter() { | |
const [number, setNumber] = useState(0); | |
let local_variable = 0; | |
let currentdate = new Date(); | |
var datetime = | |
"Last Sync: " + | |
currentdate.getDay() + | |
"/" + | |
currentdate.getMonth() + | |
"/" + | |
currentdate.getFullYear() + | |
" @ " + | |
currentdate.getHours() + | |
":" + | |
currentdate.getMinutes() + | |
":" + | |
currentdate.getSeconds(); | |
console.log("local variable", local_variable); | |
console.log(datetime); | |
local_variable++; | |
console.log("local variable", local_variable); | |
console.log("------------------------------------"); | |
return ( | |
<> | |
<h1>{number}</h1> | |
<button | |
onClick={() => { | |
setNumber(number + 1); | |
setTimeout(() => { | |
console.log("number render#1", number); | |
}, 5000); | |
setNumber(number + 1); | |
setNumber(number + 1); | |
setTimeout(() => { | |
console.log("number render#2", number); | |
}, 8000); | |
}} | |
> | |
+3 | |
</button> | |
</> | |
); | |
} |
Author
AlbertProfe
commented
Feb 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment