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 message = 'hello from a closure' | |
setTimeout(() => { | |
console.log(message) | |
}, 1000) | |
// or, same thing on one line | |
setTimeout(() => console.log(message), 1000) |
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
// Callbacks! | |
// Reminder: Run this with quokka if you want to see results instantly in your editor. | |
// https://quokkajs.com/ | |
// Part 1 | |
// If I gave you an array of numbers, and told you to list just the odds, you might do this: | |
var numbers = [1, 2, 3, 4, 5, 6]; | |
var odds = []; |
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
// Using RenderProps (https://github.com/ReactTraining/react-subjects/blob/master/subjects/RenderProps/exercise.js), | |
// how can I: | |
// | |
// 1) compose multiple fetches to be run simultaneously? In the example below, fetching credits would be blocked until | |
// debits have been fetched. | |
// | |
// 2) test the component without the fetches happening? Normally I'll have a component that takes props, and connect it | |
// to redux, and export both the connected component (as default) and the so-called presentational component as a named | |
// const. This allows me to preview the render using e.g. React Storybook. |