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
<style> | |
html, body { | |
margin: 0; | |
padding: 0; | |
} | |
.container { | |
align-items: center; | |
background-color: #EEEEEE; | |
display: flex; |
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'; | |
const useInput = (initialValue = '') => { | |
const [value, setValue] = useState(initialValue); | |
const [touched, setTouched] = useState(false); | |
const onChange = (newValue) => { | |
setValue(newValue); | |
setTouched(true); | |
} |
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'; | |
const useDebounce = () => { | |
const [timer, setTimer] = useState(null); | |
const debounce = (callback, time) => (e) => { | |
e.persist(); | |
if (timer) { | |
clearTimeout(timer); |
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
const EventEmitter = require('events'); | |
const event = new EventEmitter(); | |
// THIS IS THE IMPORTANT BIT | |
const eventPromise = (accepted, rejected, acceptMessage = '', rejectMessage = '') => new Promise((resolve, reject) => { | |
event.on(accepted, (...args) => { | |
event.removeAllListeners(accepted); | |
event.removeAllListeners(rejected); |
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
const fs = require('fs'); | |
const path = require('path'); | |
const chalk = require('chalk'); | |
const appDirectory = fs.realpathSync(process.cwd()); | |
const resolveApp = relativePath => path.resolve(appDirectory, relativePath); | |
const cmd = (command) => { | |
const { exec } = require('child_process'); |