React Components Flashcards

1
Q

What is a React.Component?

A

Is a simple javascript class that must be inherited to write a react component.

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

How parameters are sent to the component?

A

Via the props parameter

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

How to have the vscode html helpers even on javascript files?

A

By configuring the emmet settings.json to:

"emmet.includeLanguages": {
    "javascript": "html"
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the render method returns?

A

a React element

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

How to interpolate javascript in a JSX structure?

A

By the use of the curly brackets { }

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

What is the method that is always called when you create a react component?

A

render(){

}

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

How to do string interpolation on javascript?

A

the string needs to be defined with `` and the var with ${ }

alert(this is the flashcard no ${number}.

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

Where the react component keeps values to be used later on?

A

In the react’s superclass state property

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

What to do with the javascript class when you need to implement the constructor?

A

You need to call super(props) in order to call React’s constructor - normal oop

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

Should all react components’ constructor start with a super(props)?

A

Yes… All React component classes that have a constructor should start with a super(props) call.

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

What happens when you call setState in a react component?

A

It refreshes itself and also all the child components.

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

What is the React Developer Tools?

A

React Developer Tools is a tool that allows you to inspect a React tree, including the component hierarchy, props, state, and more. To get started, just open the Firefox devtools and switch to the “⚛️ Components” or “⚛️ Profiler” tab.

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

What is a controlled component?

A

Is when a component does not have its own state, instead it receives delegates to call and inform changes to the parent component.

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

What is immutability in React?

A

Is when instead of changing the object’s data, you create a new instance of object and replace the existing object with the updated one.

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

Why is immutability important?

A

Complex features become simpler (time travel) and also the change detection mechanism works best once the object instance changes (instead of its content only).

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

What is the main benefit of immutability?

A

The main benefit of immutability is that it helps you build pure components in React. Immutable data can easily determine if changes have been made which helps to determine when a component requires re-rendering.

17
Q

What is a function component and what is the benefits of using one?

A

In React, function components are a simpler way to write components that only contain a render method.

18
Q

When to use a function component?

A

When the component don’t have their own state…

19
Q

Can a component change the props?

A

No, it can only change its own state.

20
Q

What are the four ways to create a react component?

A

React.createClass (deprecated), extends React.Component, Function component and Arrow Functions…

21
Q

What is a container component? What are common “attributes” of such component?

A

A component that has little to no markup. Tie other presentation components together. Knows about Redux. Stateful.

22
Q

What is a presentation component? What are common “attributes” of such component?

A

Dumb. Full of markup. Receives data and actions via prop. does not know about Redux. Not stateful - just plain functions.

23
Q

When is it a good idea to create a container component?

A

When the props a component received is not used and just passed down.