React.js Flashcards

1
Q

What is React?

A

A JavaScript library for creating user interfaces. It is typically used with react-dom for web, and react-native for mobile.

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

What is a React element?

A

A React element is when the element is created using React.createElement.

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

How do you mount a React element to the DOM?

A

To mount a React element, ReactDOM.render() method is required. The React element and it’s container is needed for the arguments.

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

What is JSX?

A

JSX is a syntax extension to JavaScript. It is mainly used with React to help describe how the UI should look.

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

Why must the React object be imported when authoring JSX in a module?

A

.

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

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

Webpack and Babel must be installed to the devDependencies. The npm packages react and react-dom are also required. Then running the build script to compile it all.

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

What is a React component?

A

Components allow splitting the UI into independent pieces so they are more reusable and fit more situations.

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

How do you define a function component in React?

A

Function keyword followed by the function name followed by the code block that returns the JSX syntax.

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

How do you mount a component to the DOM?

A

By using the render method. The arguments would be the React element and the container which is the DOM query.

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

What are props in React?

A

.

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

How do you pass props to a component?

A

.

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

How do you write JavaScript expressions in JSX?

A

.

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

How do you create “class” component in React?

A

Class keyword followed by the function name followed by the extends keyword then React.Component. Curly braces for the code block that include render() being defined, and a code block inside that as well to return the React element being created.

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

How do you access props in a class component?

A

When using the props in a class component, the object this has to be used to define where props is coming from.

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

What is the purpose of state in React?

A

.

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

How to you pass an event handler to a React element?

A

.

17
Q

What are controlled components?

A

A controlled component allows React to control when the state of form elements change by using setState().

18
Q

What two props must you pass to an input for it to be “controlled”?

A

onChange and the value

19
Q

What Array method is commonly used to create a list of React elements?

A

array.map()

20
Q

What is the best value to use as a “key” prop when rendering lists?

A

A unique string or ID for your key.

21
Q

What makes react so powerful? Is it the this.state and this.setState() and giving control of the DOM to react?

A

.

22
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

The specific request would be included as the 2nd argument for fetch. The second argument would have an object literal and then the method property inside of it followed by the request.

23
Q

How do you pass data to a child component?

A

.

24
Q

What does fetch() return?

A

The fetch returns a promise.

25
Q

What is the default request method used by fetch()?

A

GET