Fundamental Concepts of React Module #75 Flashcards

1
Q

What’s the main reason React gained popularity so quickly

A

It made was much more easy to port apps to it than the likes of Ember.js or Angular.js

This was due also to it being a less complex framework than the others.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 4 main concepts one must understand when learning React

A
  1. Components
  2. JSX
  3. State
  4. Props
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we get a React project up and running quickly?

A

Run: npx create-react-app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we compile a React App?

A

npm start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command do we use to test our app with Jest?

A

npm test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does npm eject do?

A

When you “eject” a react app it means you’re disconnecting the app from any future updates to the framework.

You gain more flexibility from Babel and Webpack configurations, but since ejecting is irreversible, do so as sparingly as possible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Pop Quiz: What’s the difference between a standard CodePen and a CodePen Project?

A

Pens are designed for a project with a single JS file and projects accept multiple files for example, a React App.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

There is a caveat when using CodePen with regard to ES Modules, what is it?

A

Instead of using the “import” syntax as is common with ES6, instead you would write it like so:

const { useState } = React

VS the typical convention

import { useState } = React

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What’s all this talk about React using a “declaritive” approach to building user interfaces?

A

It means that you can build UI’s without touching the DOM (think document.querySelector or jQuery) and you can have an event system without having to interact with DOM events.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what does prop.children do?

A

It is used to inject components into other components.
For example: adding links to a sidebar dynamically

const Sidebar = (props) => {
  return {props.children}
}
and you embed more components into it in a transparent way:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a higher order component?

A

When a component receives a component as a ‘prop” and returns a component, it’s called a higher order component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does React use the setState method to update the DOM?

A

When setState( ) is called on a component and the state has changed, React marks it as dirty. React only updates when a Component changes states explicitly.

  • This runs the ‘diffing’ algorithm to reconcile changes
  • Then the real DOM is updated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why is the virtual DOM helpful? What is batching?

A

The virtual DOM is what React uses as a model to update the real DOM, except it does so in “batches” instead of one at a time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Unidirectional Data Flow, what is the definition? How does React take advantage of this concept?

A

The idea here is that data has only one way to be transferred to other parts of the app.

React uses this concept to:

  • pass the state to the view and child components
  • actions are triggered by the view
  • actions can update the state
  • the state change is passed to the view and child components
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What 3 objects interact with each other to update the DOM?

A

> View > Actions > State >

The view is the result of the application state which gets updated when actions take place.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List 3 advantages of one-way bindings

A
  1. Less error prone
  2. Easier debugging
  3. More efficient
17
Q

How is React written in terms of casing style?

A

Camel case.

onKeyUp, onFocus,onChange, onMouseDown, onSubmit

18
Q

Are there any dev tools at our disposal in the form of browser extensions to help us develop in React?

A

YEP. Chrome and FF both have React Dev Tools. Once you’ve installed the React devtools 2 new panels are introduced; components and profiler.

If you move the mouse over the components you set that the browser highlights the parts of the page that are rendered by that component. And if you select any component in the tree the panel show a reference to the parent.

19
Q

What does the eye icon do in React Dev Tools?

A

It allows you to inspect DOM elements

20
Q

What does the bug icon do in React Dev Tools?

A

This logs component data to the console.

21
Q

Once data is printed to the console, what more can be done with it?

A

It can be saved now as a global variable.

22
Q

How can we get a little look into the source code of components?

A

By clicking “Source Maps” which are loaded automatically by Next.js

23
Q

What is the “Profiler Tab” used for?

A

It allows us tor record an interaction betwen two components.