React Context
: pass through App -> Sidebar + ( Dashboard -> AddComment)
- Provider: Owner
- Consumer(s)
- share the parent
- a subtree of the provider
argument = null => inaccessible to the provider
value = {42} => give the value to the CurrentUserContext.Provider, give access
{ value =>
} => give CurrentUserContext.Provider a Function
–> Modify
Hooks
- Classes
- Reuse stateful logic is hard
- Logic spread into lifecycle methods
Only call hooks at/from…
- the top level
- function components or custom hooks
Function Components
- function name with ‘use’
- useState()
setCounter(counter+1) => (update): counter = counter+1
- useEffect()
- useEffect without [] (initializing) => call setInterval exponentially (setInterval itself calls the function exponentially, it’s like ex*ex)
- useContext()