-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjavascript.json
59 lines (52 loc) · 1.91 KB
/
javascript.json
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
{
////////////////////////////////////////////////////////////////////////////
// React Snippets //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
"[REACT] Scroll to Ref": {
"prefix": "scrollToRef",
"body": [
"const myRef = useRef(null);",
"const scrollToRef = (ref) => ref.current.scrollIntoView({behavior: 'smooth'});",
"useEffect(() => scrollToRef(myRef), []);",
"<div ref={myRef}>This is the content to scroll to...</div>",
"<button onClick={() => scrollToRef(myRef)}>Scroll button</button>"
],
"description": "Scroll to a div reference using useRef hook"
},
"[REACT] useState": {
"prefix": "useState",
"body": ["const [$1, $2] = useState($3);"],
"description": "Create a functional state hook"
},
////////////////////////////////////////////////////////////////////////////
// Node Snippets ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
"[Express] Express Start Server": {
"prefix": "expressStart",
"body": [
"const express = require('express');",
"const app = express();",
"",
"const publicPath = path.join(__dirname, '../public')",
"app.use(express.static(publicPath))",
"",
"app.get('', (req, res) => res.send('hello'));",
"app.listen(3000, () => console.log(`Server is running on 3000...`));"
]
},
////////////////////////////////////////////////////////////////////////////
// JavaScript Snippets /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
"[JavaScript] Console log": {
"prefix": "log",
"body": "console.log();"
},
"[JavaScript] Google Map": {
"prefix": "gmap",
"body": [
"new google.maps.Map(document.getElementById('$1'), {",
"\tzoom: 1, center: {lat: $2, lng: $3}",
"})"
]
}
}