From 67619c9db5430c258bf5f184f5f3e3f6e2c00fd9 Mon Sep 17 00:00:00 2001 From: Nathan Velliquette Date: Thu, 4 May 2023 02:42:54 -0400 Subject: [PATCH] documentation: Update verbiage to be more readable While reading this section, this particular sentence read awkwardly to me even as a native speaker. Particularly between the implied pause between "though" and "it". I understand the intent and it might be just me; since it gave me pause, I thought it might be worth addressing. --- src/exercise/02.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/exercise/02.md b/src/exercise/02.md index 18f5b184f..73aba7497 100644 --- a/src/exercise/02.md +++ b/src/exercise/02.md @@ -10,8 +10,8 @@ Elaborate on your learnings here in `src/exercise/02.md` Memoization: a performance optimization technique which eliminates the need to recompute a value for a given input by storing the original computation and -returning that stored value when the same input is provided. Memoization is a form -of caching. Here's a simple implementation of memoization: +returning that stored value when the same input is provided. Memoization is a +form of caching. Here's a simple implementation of memoization: ```typescript const values = {} @@ -122,7 +122,7 @@ React.useEffect(() => { }, [updateLocalStorage]) // <-- function as a dependency ``` -The problem with that though it will trigger the `useEffect` to run every +The problem with doing that is that it will trigger the `useEffect` to run every render. This is because `updateLocalStorage` is defined inside the component function body. So it's re-initialized every render. Which means it's brand new every render. Which means it changes every render. Which means... you guessed @@ -227,8 +227,8 @@ some fancy things with dependencies (dependency arrays are the biggest challenge to deal with when making custom hooks). NOTE: In this part of the exercise, we don't need `useCallback`. We'll add it in -the extra credits. It's important that you work on this refactor first so -you can appreciate the value `useCallback` provides in certain circumstances. +the extra credits. It's important that you work on this refactor first so you +can appreciate the value `useCallback` provides in certain circumstances. ## Extra Credit @@ -305,7 +305,12 @@ function that people can call in their own `useEffect` like this: ```javascript // πŸ’° destructuring this here now because it just felt weird to call this // "state" still when it's also returning a function called "run" πŸ™ƒ -const {data: pokemon, status, error, run} = useAsync({ status: pokemonName ? 'pending' : 'idle' }) +const { + data: pokemon, + status, + error, + run, +} = useAsync({status: pokemonName ? 'pending' : 'idle'}) React.useEffect(() => { if (!pokemonName) {

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /