React Context LOs

React Context

React Context gives you a way to pass data through the component tree without having to manually thread props.

React Context will re-render ALL of the children of a Component. React is specifically designed to cause small modular re-renders of components. So, we DO NOT want large swaths of our page re-rendering frequently, as this defeats the purpose of React. Therefore, React Context should be used for big, infreqeunt changes to your webpage.

Ex: * Switching to Dark Mode * Sending a User’s information

React Context should NOT be used for: * Live updates * Anything which is loaded when scrolling a page * Small or frequent updates to a page

PupContext Homework Solutions

React.createContext

Context.Provider

Context.Consumer

Updating Context Value

Command to set up a simple React App

Assessment Prep

Project Solutions

Context To Do List Solutions

Twitter Revisited Solutions