React Flashcards

1
Q

What is React?

A

A JS library for building UI’s

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 the element

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(element, container)

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

What is JSX?

A

A JavaScript syntax extension

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 compiles into React.createElement

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 transform react jsx

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

What is a React component?

A

A function that accepts a prop and returns a react element

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 FuncName(props){
return (<h1>hi</h1>);
}
function keyword followed by function name with parameter props.. inside code block return statement with element that represents DOM tags
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(, container)

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

What are props in React?

A

A javascript object

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

function name with variable initialized to prop value

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

expression inside 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 keyword FunctionName extends React.Component opening code block render() definition code block
return react element
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.element

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

Represents information on the elements current situation and allows it to be updated

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

eventName={eventHandler}

name of the event equals the event handler inside of curly braces

17
Q

What are controlled components?

A

The component that renders the form also controls what happens on user input and keeps the form data in the state

18
Q

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

A

onChange & value

19
Q

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

A

map

20
Q

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

A

a property in the object