React Flashcards

1
Q

What’s the virtual DOM?

A

Virtual Dom is an in memory representation of the actual html elements . When a component is rendered, the virtual DOm compares the change to its model of the DOM in order to create a list of updates to applied.

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

What is JSX ?

A

JSX is an extension to Javascript syntax that allows for writing code that looks like HTML.

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

What’s the difference between a class component and a functional one?

A

Class-based components were used to create components that needed to maintain internal state or utilize lifecycle methods.
Functional components are stateless and return the output to be rendered.

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

What are keys used for?

A

Keys help React identify which items have changed, are added, or are removed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. What’s the difference between state and props?
A

Props are data that are passed into a component from its parent. (should be read-only, when declare function/class, it never modify its props);
Sate is a component’s internal data that can be modified during the lifetime of the components and it’s maintained between re-renders.

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

Why call setState instead of directly mutating state?

A

If you try to mutate a component’s state directly, React has no way of knowing that it needs to re-render the component. By using setState, React can update components UI

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

Why call setState instead of directly mutating state?

A

If you try to mutate a component’s state directly, React has no way of knowing that it needs to re-render the component. By using setState, React can update components UI

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

What’s prop drilling, and how can you avoid it?

A

Props drilling is when you need to pass to data from a parent component down to a component lower in the hierarchy, drilling through other components that have no need for the props themselves.
Avoid: refractoring components, keep common state in the closest common parent. If deep down, considere react context api, redux

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

What’s React context?

A

Context provides a way to pass data through the component tree without having to pass props down manually at every level.
(implicit prop)

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

Redux

A

A state management library that introduces before context api

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

Advantage of React

A

easy to learn and use
virtual dom to improve efficiency
easier to create dynamic web page
MVC architeture

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

Limitation of React

A

The speed of development is so fast that the documentation cant keep up
Complexity of learning
jsx can be a barrier

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

React

A

a javascript library which is used to built user interfaces especially single-page application

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

Major features of React

A

use virtual dom instead of realdom
support server-side rendering
Follows Unidirectional data flow or data binding.(round: state => views => action)
use reusable/composable UI rendering

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

React Hooks

A

Hooks is a new feature(React 16.8) that lets you use state and other React features without writing a class.

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