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

it’s an 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

with the render method of the ReactDOM object

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

What is Babel?

A

Babel is a JavaScript compiler that rewrites 2015+ JavaScript to earlier versions

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

What is a plug-in?

A

a plug-in is a piece of software that adds a specific feature to an existing computer program. enabling plug-ins enables customization

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

What is a Webpack loader?

A

transformations that are applied to the source code of a module. allows you to pre-process files as you import or load them such as converting TypeScript to JavaScript

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

How can you make Babel and Webpack work together?

A

babel-loader

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 for JavaScript. Syntactic sugar for React

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 JSX produces React objects

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 JavaScript?

A

babel loader

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

What is a React component?

A

A React component is a function in React

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
function keyword
Component name (CAPITALIZED)
option (props) parameter
return React elements
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

you assign the return to a variable and then call the render method of the root object. passing the variable as an argument

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

What are props in React?

A

props are Objects and serve as parameters that we can pass to Components

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

you would “call” your component followed by your prop with a value assigned to it

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

How do you write JavaScript expressions in JSX?

A

use {curly braces}

17
Q

How do you create “class” component in React?

A
class ClassName extends React.Component
a mandatory render() method
18
Q

How do you access props in a class component?

A

this

19
Q

What is the purpose of state in React?

A

state gives some control to Class Components. it allows us to do things based off of what the current state is. like view swapping

state is a data model
keeping track of variables that change over time

20
Q

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

A

you pass it as a props to a React element

and pass a callback

21
Q

What are controlled components?

A

a React component that renders a form and also controls what happens in that form on user input

22
Q

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

A

a prop for that input’s value

an onChange event

23
Q

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

A

the map() method

24
Q

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

A

a string that uniquely identifies a list item among its siblings or an ID from data keys