React Flashcards

1
Q

What is React?

A

a JS library for building UI

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

What is a react element?

A

Object

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

Query select the element to attach it too, createRoot method and then the render method.

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

What is Babel?

A
  • A javascript compiler, takes new JS to convert it backwards.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a plug in?

A
  • An add-on that adds a special feature to a program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • What is a Webpack loader?
A
  • Transformations applied to the source code of a module
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to make Babel and Webpack work together

A

By using webpack, babel and babel-loader to link the two.

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

What is JSX?

A

JSX is a syntax extension to JS, it produces react elements

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

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

A

Because the compiled output calls react.createElement()

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

how can you make webpack and Babel work together to convert JSX into valid JS?

A

Babel loader and the transform-react-jsx plug in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
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
12
Q

how do you define a function component in React

A

start with a capital letter, optional props parameter, it has to return react element.

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

How do you mount a component to the DOM?

A

Create a react element from a component and pass it to the render method of the root object.

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

what are props in React?

A

Object properties used to pass data from one component to another

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

How do you pass props to a component?

A

Type the react element, type the props which look like attributes, if its not a string use curly brackets

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

how do you write JS expressions in JSX?

A

wrap in curly brackets

17
Q

How do you create class component in React?

A

Class ClassName extends React.Component {
render() {}
}

18
Q

How do you access props in a class component

A

this.props

19
Q

What are controlled components?

A

the values of the inputs are stored in the state of the components

20
Q

What two props do you need to pass to an input to be considered controlled?

A

value and onChange

you dictate with the react state what the value of the input should be.

21
Q
  • What is the purpose of state in React?
A
  • Keeps track of values that change over time
22
Q
  • How to you pass an event handler to a React element?
A
  • As a prop, the prop name is the event you are listening for. The JavaScript expression containing the function.
23
Q
  • WhatArraymethod is commonly used to create a list of React elements?
A
  • Map
24
Q
  • What is the best value to use as a “key” prop when rendering lists?
A
  • The ID from your data
25
Q
  • What doesfetch()return?
A
  • It returns a promise for the response
26
Q
  • What is the default request method used byfetch()?
A
  • Get
27
Q
  • How do you specify the request method (GET,POST, etc.) when callingfetch?
A
  • Give it a second argument of an object containing the method to use.
28
Q
  • When does React call a component’scomponentDidMountmethod?
A
  • is invoked immediately after a component is mounted (inserted into the tree).
29
Q
  • Name three React.Component lifecycle methods
A
  • Constructor, render, componentDidUpdate, componentDidMount.
30
Q
  • How do you pass data to a child component?
A
  • Pass a prop as a JS expression.