React Flashcards

1
Q

What is React?

A

React is a JavaScript library for creating user interfaces.

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 an object representation of a DOM node.

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

ReactDom.render

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

What is JSX?

A

a syntax extension to JavaScript. We recommend using it with React to describe what the UI should look like.

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

JSX just provides syntactic sugar for the React.createElement(component, props, …children) function

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

babel-loader and the plugin

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

What is a React component?

A

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

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 CustomBtn() {
  return Click Me!;
}

“return jsx”

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

ReactDOM.render

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

What are props in React?

A

It is an object which stores the value of attributes of a tag and work similar to the HTML attributes.

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

Define a function and pass it as a parameter

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

wrap them with curly braces

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 and extends

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

this.props.whateverhere

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

represent an information about the component’s current situation

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

Pass event handlers and other functions as props to child components:

17
Q

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

A

.map

18
Q

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

A

The best way to pick a key is to use a string that uniquely identifies a list item among its siblings. Most often you would use IDs from your data as keys:

19
Q

What are controlled components?

A

those in which form data is handled by the component’s state.