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 the user can see

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

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

A

syntax extension to JS, allows users to write HTML elements in JS and place them in the DOM without createElement()/appendChild() methods

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

React library must be within the scope as you are calling things from it

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 takes babel loader with plugin-transform-react-jsx to translate jsx to javascript and compile into another file

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

What is a React component?

A

function (class) that returns react elements

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

same as JavaScript function definition

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

call reactDOM.render(, DOM)

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

What are props in React?

A

props are objects which are arbitrary inputs

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

add it as a parameter in the function and call it within the function definition as {props}

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

within curly brackets { }

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 className extends React.Component {
render() {
}
}
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

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

hold information that is managed within the component (like variables in a function)
State is an object that determines how that component renders and behaves

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

onClick={ }

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

IDs from data

19
Q

What are controlled components?

A

An input form element whose value is controlled by React with value prop and an onChange listener

20
Q

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

A

value and onChange