React.js 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

smallest building blocks of react - also describes what the DOM should look like

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

using ReactDOM.render()

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

What is JSX (JavaScript XML)?

A

A syntax extension to JavaScript that provides a way to structure component rendering using syntax familiar to many developers

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

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

A

Importing React is necessary because Babel compiles JSX down to React.createElement() calls

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 will allow babel loader to identify JSX needs to compiled and you can use Babel loader to compile JSX and transform JSX plug-in is necessary for babel to know

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

What is a React component?

A

review again - React component is sth

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 with a return statement like 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

Using ReactDOM.render(, document.querySelector(‘#id’));

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

What are props in React?

A

review again - Props are properties that are basically kind of global variable or 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

review again - component name key = string or javascript expression

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

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

with keyword class className extends keyword React.Component with render() method

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

use this keyword

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

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 do you pass an event handler to a React element?

A

you pass an event handler via prop

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: The best way to pick a key is to use a string that uniquely identifies a list item among its siblings. Most often you would use IDs from your data as keys

19
Q

What are controlled components?

A

example is input element - Controlled components are react are fully wired into it and pass in value prop and onChange components

20
Q

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

A

value and type and onChange