reading-notes

Notes for Codefellows Code 401 301 201 and 102

Reading Class 33: Context API

Describe use cases for useMemo() and useReducer()

source useMemo()You’re noticing a component’s render is frustratingly slow, and you’re passing a calculation to an unknowable number of children, such as when rendering children using Array.map()… or Your app often becomes unresponsive because you’re fetching a large amount of data, and having to transform it into a usable format

source useReducer()is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one. useReducer also lets you optimize performance for components that trigger deep updates because you can pass dispatch down instead of callbacks.

Why do custom hooks need the use prefix?

source So that you can tell at a glance that the rules of Hooks apply to it

What do custom hooks usually do?

source Custom hooks allow us to have cleaner functional components, remove logic from the UI layer, and prevent code duplication by bringing common use cases to reusable hooks.

Using any list of custom hooks, research and name one that you think will be useful in your applications

source useLocalStorage,useArray, useReducer

Describe how a hook that fetches API data might work

source - Julien Edwards - go Julien need to set a loading state to flag when teh async is done - useEffect doesn’t play with async -

Document the following Vocabulary Terms

reducer

source a function that determines changes to an application’s state. It uses the action it receives to determine this change.

Preview

Skim the following materials in preparation for the upcoming lecture. Note the following as you browse the material, and be prepared to participate in discussions during lecture

Preparation Materials