411 Week 4-Halfway through

Monica Suarez
2 min readOct 12, 2020

Now that we are halfway through the course, things are really getting rolling. This week was the second week of working on checkpoint projects with classmates, and when I got started with the rudimentary tasks to start on my capstone project.

Discuss in words something you learned in class today or this week. | We learned about protected routes.

How does hoisting work in JavaScript? | Hoisting is a mechanism where variables and function declarations are moved to the top of their scope before code execution, regardless if their scope is local or global.

Why is setState() in React Async instead of Sync? | This is because setState() alters the state and causes re-rendering.

How is the Virtual-DOM more efficient than Dirty checking? | The virtual DOM is used for efficient re-rendering of the DOM. This isn’t really related to dirty checking data. One could re-render using a virtual DOM with or without dirty checking.

What is PureComponent? When to use PureComponent over Component? |
PureComponent is exactly the same as Component except that it handles the shouldComponentUpdate method for you . When props or state changes, PureComponent will do a shallow comparison on both props and state.

What is a higher order component? | Higher-order components (HOC) are a very similar concept to higher order functions. Instead of working with functions as input parameters and return values, HOCs are working with components. A HOC takes a component as input parameter and returns a new component. This HOC takes a React component, WrappedComponent, as parameter. It returns a new React component. The returned component contains the WrappedComponent as a child.

Which (if there is) node library method could you use to solve the algorithm problem you solved last night in your pre-homework. | We used react-router-dom to create a BrowserRouter component.

Which (if there is) node library method could you use to solve the algorithm problem you solved in class tonight? | We used @material-ui/core to bring in components like Paper and Chip to create a sleek UI for our homework.

How do you think you might use the checkAuth() function to actually verify a user's email and password? |

// in src/authProvider.js
export default {
login: ({ username, password }) => { /* ... */ },
getIdentity: () => { /* ... */ },
logout: () => { /* ... */ },
checkError: (error) => { /* ... */ },
checkAuth: () => localStorage.getItem('auth')
? Promise.resolve()
: Promise.reject(),
// ...
};

--

--