deeply about what “state” even means in a React application. • Learn a bit about the inner workings of this.setState. • How class-based component state and hooks differ. • Explore APIs for navigating around prop-drilling. • Use reducers for advanced state management.
our own custom hooks for managing state. • Store state in Local Storage. • Store state in the URL using query parameters. • Fetch state from a server—because that’s a thing.
nouns in your application. • View/UI state: Are those nouns sorted in ascending or descending order? • Session state: Is the user even logged in? • Communication: Are we in the process of fetching the nouns from the server? • Location: Where are we in the application? Which nouns are we looking at?
to time. • Model state: This is likely the data in your application. This could be the items in a given list. • Ephemeral state: Stuff like the value of an input field that will be wiped away when you hit “enter.” This could be the order in which a given list is sorted.
one to get warmed up. • https://github.com/stevekinney/simple-counter-react-state • It will have three buttons: • Increment • Decrement • Reset • Your job: Get decrement and reset working. • Only touch <Counter !/> for now.
that it has nothing to do with Redux. • But, it does allow you to use reducers—just like Redux. • The cool part is that it allows you to create interfaces where you (or a friend) can pass in the mechanics about how to update state.
User Board Board Board Cards Card Card Card Card User User Move to Board Assign to User Move to Board Assign to User Move to Board Assign to User Move to Board Assign to User Move to Board Assign to User Move to Board Assign to User
optimizations when moving to the Context API. • What’s the right answer? It’s a trade off. • Grudge List might seem like a toy application, but it could also represent a smaller part of a larger system. • Could you use the Context API to get things all of the way down to this level and then use the approach we had previously?
structure your state can have implications for the maintainability of your application. • It can also have some implications for performance as well. • Modern versions of React come with tools for eliminating some of the pain points that used to require third party libraries.
hook? • It should take an endpoint as an argument. • It should return response, loading, and error. • You might want the following in order to get the right data back out. • const characters = (response !&& response.characters) !|| [];
would be cool if we could use the api/search/:query endpoint to get all of the characters that match whatever is typed in that bar. • Can you implement that?
pattern that predates most of what we’re doing in the browser these days. • It allows our users to save and share the URL with all of the state baked right in.