This sheet goes along with this SSH YouTube tutorial
$ ssh [email protected]
$ mkdir test
$ cd test
$ ssh [email protected]
$ mkdir test
$ cd test
import { useState } from 'react'; | |
export default function useLocalStorage(key, initialValue) { | |
const [item, setInnerValue] = useState(() => { | |
try { | |
return window.localStorage.getItem(key) | |
? JSON.parse(window.localStorage.getItem(key)) | |
: initialValue; | |
} catch (error) { | |
return initialValue; |
/** | |
* useScroll React custom hook | |
* Usage: | |
* const { scrollX, scrollY, scrollDirection } = useScroll(); | |
*/ | |
import { useState, useEffect } from "react"; | |
export function useScroll() { | |
const [lastScrollTop, setLastScrollTop] = useState(0); |