React Flashcards

1
Q

What is React?

A

A JavaScript library for building 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

An object that describes how the DOM should look

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

What is Babel?

A

Babel is a JavaScript compiler mainly used to convert ES2015+ code into backward compatible versions for older browsers.

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

What is a Plug-in?

A

A software component that adds a specific feature to an existing program

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

What is a Webpack loader?

A

Transformations applied to modules. Allows you to preprocess files and perform other tasks during load.

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

How can you make Babel and Webpack work together?

A

Install them as dependencies and add webpack.config.js that calls the babel plugins.

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

What is JSX?

A

JavaScript Extension. JSX provides syntactic sugar for the React.createElement function, so you can call it with fewer lines of code.

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

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

A

React.createElement function is needed to render elements in JSX.

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

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

A

Install webpack, webpack-cli, babel loader, babel/core, babel/plugin-transform-react-jsx. Babel/plugin-transform-react-jsx then gets added to webpack.config.js and transforms JSX to valid JavaScript upon build.

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

What is a React component?

A

A function that return React elements

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

How do you define a function component in React?

A

Create a function with a return statement that has JSX in it.

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

How do you mount a component to the DOM?

A

Call ReactDOM render function and pass in the component and DOM node.

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

What are props in React?

A

Props are properties or children passed to a React component

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

How do you pass props to a component?

A

In the custom React tag add the name of the props = value

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

How do you write JavaScript expressions in JSX?

A

Place it in curly braces within the tags.

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

How do you create “class” component in React?

A

class extends React.Component

17
Q

How do you access props in a class component?

A

this.props

18
Q

What is the purpose of state in React?

A

React objects are immutable and must be re-rendered if you want the elements to change. Add state so that React only renders when a change happens.

19
Q

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

A

Pass the callback function in curly braces to the event prop.

20
Q

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

A

map

21
Q

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

A

id

22
Q

What are controlled components?

A

Elements with their own state that are controlled by the React element’s state

23
Q

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

A

onChange, value

24
Q

When does React call a component’s componentDidMount method?

A

Right after the component gets added to DOM

25
Q

Name three React.Component lifecycle methods.

A

componentDidMount, componentDidUpdate, componentWillUnMount, constructor, render

26
Q

How do you pass data to a child component?

A

pass a prop