Day 64: React Interview Questions Anyone?

Started working on the next React practice project. A meme generator. During the explanation there were some great questions being asked about how React features work. I decided they were worth noting and building on. The tutorial is finally throwing some real UI work in. Got API calls, forms, so now we are cooking. I already have my plans for after I finish these remaining projects. I just have to stay firm and keep pushing. I have been distracted lately and it has shown with how slow my progress has been. I am feeling better and hopefully I can produce some great results with some renewed focus!

TLDR;

Okay, so here are the highlights of what I did:

  • Practice -> Started working on the Meme Generator project from the React tutorial course. The tutorial spent almost 5 hours teaching about props state and adding functionality to React components. It was dry but the sections where questions were asked were helpful. I started writing down some notes because those questions seemed like interview questions for React positions.

React Knowledge Questions (Rough Draft)

Don’t quote me on any of these answers. I still have to go through and check to make sure and get proof from the docs and some examples.

How Would You Describe the Concept of State

A way for React to remember saved values from within a component. This is similar to declaring variables from within a component, with a few added bonuses (Which we’ll go over later…)

When would you want to Use props instead of state ?

Anytime you want to pass data into a component so that the component can determine what will get displayed on the screen.

When would you want to Use state instead of props ?

Anytime you want to a component to maintain some values from within the component. (and “remember” those values those values even when React re-renders the component).

What does Immutable mean? Are props immutable? Is state immutable?

Immutable means unchanging. Props are immutable (or they should be immutable). State is mutable.

What does it mean to raise state up?

What is derived state? Why do we not need it?

What is a side-effect in React? What are some examples?

Any code that effects an outside system.

  • local storage
  • API
  • websockets
  • two states to keep in sync (Huh? what’s that?)

What is NOT a side-effect in React? What are some examples?

Anything that React is in charge of.

  • Maintaining state
  • keeping the UI in sync with the data

When does React run the useEffect function? When does it not run the useEffect function?

  • It runs as soon as the component loads (always) and if the dependency array is provided but is empty it will only run once when the component loads.
  • On every re-render of the component (if no dependency array is provided)
  • Will NOT run the effect when the dependencies in the array stay the same between renders

How would you explain what the “dependency array” is?

  • It is the second parameter to the useEffect function.
  • It is a way for React to know whether it should re-run the effect function.

Goal For Round 7 of the #100DaysofCode Challenge

This is my seventh round of the “#100daysofcode” challenge. I will be continuing my work from round five and round six into round seven. I am currently working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal is to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.g. Git. This goal was in turn derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.

I have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects.