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 value = Symbol('value') | |
const retrieve = (node, path) => { | |
for (let i = 0; i < path.length; i++) { | |
const key = path[i] | |
if (node.has(key)) { | |
node = node.get(key) | |
} else { | |
const child = new Map() | |
node.set(key, child) |
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
// Taken (with some minor changes) from: | |
// https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback | |
import { useRef, useEffect, useCallback } from 'react' | |
const throwReferenceError = () => { | |
throw new ReferenceError('Callback was called directly while rendering, pass it as a callback prop instead.') | |
} | |
/** |
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, { useCallback, useState } from 'react' | |
const Form = () => { | |
const [profile, setProfile] = useState({ | |
firstName: 'John', | |
lastName: 'Johnsonian', | |
jobTitle: 'Jabberwocky', | |
}) | |
console.log(profile) |
OlderNewer