react Flashcards

1
Q

What is React?

A

React is a JavaScript library for building user interfaces.
- Declarative
- Component-based

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

What is the Virtual DOM?

A

The Virtual DOM (VDOM) is a programming concept where an ideal or “virtual” representation of a UI is kept in memory and synced with the “real” DOM by a library such as ReactDOM. This process is called reconcilliation

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

What are controlled components?

A

A controlled component is one that takes its current value through props and notifies changes through callbacks like onChange. A parent component “controls” it by handling the callback and managing its own state and passing the new values as props to the controleld component. You could also call this a “dumb component”

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

What is an uncontrolled component?

A

A Uncontrolled component is one that stores its own state internally, and you query the DOM USING A ‘ref’ to find its current value when you need it.

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

Why Immutability is important?

A
  • Detecting Changes
    detecting changes in mutable objects is difficut because they’re modified directly. This detection requires the mutable object to be compared to previous copies of itself and the entire object tree to be traversed. Detecting changes in immutable objects is easier, if the immutable object that is being referenced is different than the previous one, then the object has changed.
  • Determining when to re-render in React
    Immutable data can easily determine if changes have been made, which helps to determine when a component requires re-rendering
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between Function components and Class components?

A

In React, function components are a simpler way to write components that only contain a render method and don’t have their own state. Instead of defining a class which extends React.Component, we can write a function that takes props as input and returns what should be rendered. Function components are less tedious to write than classes, and many components can be expressed this way.

Currently function components are preferred amongst developers

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

What does lifting state up refer to?

A

Lifting state is accomplished by moving the state up to the closest common ancestor of the components that need it. This state is then passed to components through their props.

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