I’ve Cracked the Code, Please Call Tech Support- Episode 27, The Six Logins
More weeks pass, more React training. I finally had the “Ah-ha!” moment with this language, so things are going a lot more smoothly. Throw in Material-UI and you have a very useful set of tools.
- Discuss in words something you learned in class today or this week.
Well, kind of. Basically the browser will read the entire code before rendering anything. So, if you have a variable, it knows about it. Even if it comes after when you need it.
3. Why is setState() in React async rather than sync?
By being asynchronous, setState() can look farther afield. This prevents it from just resetting the state to what’s already there.
4. How is the Virtual-DOM more efficient than Dirty checking?
The virtual-DOM will only re-render the DOM-tree when the state changes. This is different than dirty-checking, which would check over certain intervals, rather than with an input of any kind.
5. What is PureComponent? When should you use PureComponent over Component?
PureComponents do not re-render when the state or props have been updated with the same value. Basically, if it’s the same, there’s no real reason to re-render. This prevents resources from being used unnecessarily in a resource heavy app.
6. What is a higher order component?
As per the React documentation, a higher order component is a function that takes a component and returns a new component.
7. Which (if there is) node library method could you use to solve the algorithm problem you solved last night in your pre-homework?
The pre-homework involved using protected routes, which is something that I’m very interested in, actually. I come from a security background, and using methods like ProtectedRoute really shone a light on how security is accomplished in a site or application.
8. Which (if there is) node library method could you use to solve the algorithm problem you solved in class today?
We used cookies! Keeping track of the cookies allows us to see if a user has already logged in. If they haven’t interacted with a new page after a period of time, we can keep track of this.
9. How do you think you might use the checkAuth() function to actually verify a user’s email and password?
By keeping a hashed and secured record of usernames and passwords, we can use checkAuth() to compare the input with our list. If everything checks out we can let the user in.