View docker-compose.yml
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
version: "3.8" | |
services: | |
webapp: | |
image: node:lts-alpine # always using the same image - no building, less space taken | |
working_dir: /usr/app/webapp | |
volumes: | |
- "./webapp/package.json:/usr/app/webapp/package.json" | |
- "./webapp/yarn.lock:/usr/app/webapp/yarn.lock" | |
- "./webapp/tsconfig.json:/usr/app/webapp/tsconfig.json" |
View snip.code-snippets
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
Show hidden characters
{ | |
"Print to console": { | |
"scope": "javascript,typescript", | |
"prefix": "log", | |
"body": ["console.log('$1');"], | |
"description": "Log output to console" | |
} | |
} |
View useImmerState.js
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, useCallback } from 'react' | |
import produce from 'immer' | |
const useImmerState = initialState => { | |
const [state, setState] = useState(initialState) | |
const setImmerState = useCallback(setter => setState(produce(setter)), []) | |
return [state, setImmerState] | |
} |
View window-size-with-own-hook.js
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 React from "react"; | |
import useWindowSize from "./useWindowSize"; | |
const WindowSize = () => { | |
const { width, height } = useWindowSize(); | |
return ( | |
<> | |
<h2>Window size: {width} x {height}</h2> | |
</> | |
); |
View useWindowSize.js
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, useEffect } from "react"; | |
export default function useWindowSize() { | |
const [{width, height}, setSize] = useState({ window.innerWidth, window.innerHeight }); | |
useEffect(() => { | |
const handleResize = () => setSize({ window.innerWidth, window.innerHeight }); | |
window.addEventListener("resize", handleResize); | |
return () => { | |
window.removeEventListener("resize", handleResize); |
View hooks.js
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 React, { useState, useEffect } from "react"; | |
const WindowSize = () => { | |
const [{width, height}, setSize] = useState({ window.innerWidth, window.innerHeight }); | |
useEffect(() => { | |
const handleResize = () => setSize({ window.innerWidth, window.innerHeight }); | |
window.addEventListener("resize", handleResize); | |
return () => { | |
window.removeEventListener("resize", handleResize); | |
}; |
View class-component.js
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 React, { Component } from "react"; | |
class WindowSize extends Component { | |
state = { | |
width: window.innerWidth, | |
height: window.innerHeight | |
}; | |
handleResize = () => this.setState({ | |
width: window.innerWidth, |
View api.js
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
export const request = async (url, method = 'GET', type = 'json', body = null) => { | |
const requestOptions = { | |
method: method, | |
headers: { 'Content-Type': 'application/json' }, | |
}; | |
if (body) { | |
requestOptions.body = JSON.stringify(body); | |
} | |
if (type === 'json') { | |
return await (await fetch(url, requestOptions)).json(); |
View Counter.vue
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
<template> | |
<section class="section"> | |
<div class="container"> | |
<h2 class="title">{{title}}</h2> | |
<div class="level"> | |
<div class="level-item"> | |
<button class="button" @click="incrementCounter"> | |
<span class="icon"> | |
<i class="fa fa-plus"></i> |
View FormSample.js
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 React, { Component } from "react"; | |
export default class FormSample extends Component { | |
state = { | |
employer: "Gorrion" | |
}; | |
handleEmployerChange = e => { | |
this.setState({ employer: e.target.value }); | |
}; |
NewerOlder