ACA 400 — Week 4 Interview Questions
Discuss in words something you learned in class today or this week.
We covered React Router, something instrumental for Single Page Applications. React is wonderful for creating SPA, and to be able to provide navigable urls we need to use Routes.
hoisted = true;
console.log(hoisted) //outputs true
Even though “hoisted” is declared after it is assigned “true” the console.log outputs “true”.
ES6 let and const variable declaration makes hoisting impossible and that’s good. It’s cleaner and less difficult to follow the flow of the code.
setState() in React Async instead of Sync?
As I quoted in the last set of interview questions from React deocumentation:
This ensures, for example, that if both
setStateduring a click event,
Childisn’t re-rendered twice. Instead, React “flushes” the state updates at the end of the browser event. This results in significant performance improvements in larger apps.
How is the Virtual-DOM more efficient than Dirty checking?
It’s reusable, instead of re-rendering a whole page on information change Virtual Dom allows us to change/update in the DOM only what has been changed in the data.
PureComponent? When to use
The easy answer is to prevent re-rendering of a child component when it’s parent component re-renders if the props on the child component do not change. It’s a way to improve performance.
What is a higher order component?
From React Documentation:
Concretely, a higher-order component is a function that takes a component and returns a new component.
Might look something like this:
const EnhancedComponent = higherOrderComponent(WrappedComponent);
While not exactly part of the React API per-se, HOC are a result of React’s compositional nature. HOC’s can be used to transform a component into a different component.
Which (if there is) node library method could you use to solve the algorithm problem you solved last night in your pre-homework.
…still enigmatic, still confusing. I need to know the algorithm.
Which (if there is) node library method could you use to solve the algorithm problem you solved in class tonight?
How do you think you might use the
checkAuth() function to actually verify a user's email and password?
I’d imagine there would be checking against a database of email addresses. Probably paired with a fetch call to the database and a confirmation of existence in the database.