-
Notifications
You must be signed in to change notification settings - Fork 0
/
egnyte.js
81 lines (60 loc) · 1.34 KB
/
egnyte.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
egnyte
//1.
// 'use client';
// import { useEffect, useState } from 'react';
// const StaleClosure = () => {
// const [count, setCount] = useState(0)
// console.log('first', count);
// useEffect(() => {
// setCount(count => count + 1)
// },[])
// useEffect(() => {
// console.log('effect', count);
// setTimeout(() => {
// console.log('timeout', count);
// }, 100)
// },[])
// return null
// }
// export default StaleClosure;
// 2.
// firstRender = useFirstRender();
// function useFirstRender() {
// const [firstRender, setFirstRender] = useState(false);
// useEffect(() => {
// setFirstRender(true)
// }, [])
// return [
// firstRender
// ]
// }
// 3.
// count() // 1
// count() // 2
// count() // 3
// count.reset() // 0
//4.
// console.log(add1(1,2))
// console.log(add2(1,2))
// console.log(add3(1,2))
// console.log(add4(1,2))
// function add1(a,b) {
// return a + b
// }
// const add2 = (a,b) => {
// return a + b
// }
// let add3 = function (a,b) {
// return a + b
// }
// var add4 = function (a,b) {
// return a + b
// }
// 2. Event loop
// setTimeout(() => console.log(1), 0);
// console.log(2);
// new Promise(res => {
// console.log(3)
// res();
// }).then(() => console.log(4));
// console.log(5);