React Flashcards

1
Q

What is reconciliation?

A

Reconciliation is the process through which React updates the DOM. When a component’s state changes, React has to calculate if it is necessary to update the DOM. It does this by creating a virtual DOM tree and comparing it with the current DOM tree.

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

Why do you need to write ‘className’ instead of ‘class’, and ‘htmlFor’ instead of ‘for’ when referring to html attributed in JSX?

A

Since JSX isn’t a standard language and gets transpiled to JavaScript it can’t use reserved words in JavaScript like class and for

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

What is babel and what is it used for?

A

It is used to transpile ES2015 and JSX into ES5 and Javascript, because browsers don’t support ES2015 out the box and JSX isn’t a standard language, and is designed to be changed to JavaScript anyway (e.g <div></div> in JSX === React.createElement(“div”))

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

What is an Element in React?

A

Is is a special type of object that is to represent a node in the DOM tree, created by using React components. The way that React components are changed into elements and made into a virtual DOM tree is known as reconciliation

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

When do you use a stateful component instead of a stateless component?

A

If you need to re render a component then store a value in state, as a component re renders when state changes.
Only store values in state when you intent to access these values in the render method

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

What’s the difference between client side rendering and server side rendering?

A
  • Client side rendering is when a server returns an empty html file with a js bundle that runs when loaded on the client side
  • Server side rendering is when you render the application on the server and serve the application content to the client directly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why would you need SSR? (2)

A
  • If you want SEO

* If you want to reduce the effect of havint a large bundle size (i.e improve perceived performance)

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

What is a Higher order Component in React?

A

Functions that take a component and return an enhanced component. This can be used to abstract logic away from components, allowing components to be more dumb and testable, and containing logic and, for example, data fetching in HoC’s. <div><img></img></div>

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

Why do SVGs work so well with React?

A

In terms of returning jsx from a function, React doesn’t care if it’s a <div> or an , and SVGs are defined in a very declarative way, so you can harness the declaritive nature of React to create SVGs in a Component and using props to change SVG properties dynamically.</div>

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