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

Not a DOM object but just a plain JavaScript 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Babel?

A

JavaScript Compiler

back conscripting javascript code

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

What is a Plug-in?

A

software component that adds a specific feature to an existing computer program

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

What is a Webpack loader?

A

Loaders are transformations that are 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 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

it is a syntax extension to JavaScript that 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

JSX creates react elements and so it relies on React object to be able to produce the element

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

A

Babel loader and other plugins

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

Literally JavaScript functions

function CustomButton( ) {
  return Click Me!< /button >;
}
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

query select for element to append to
create react.root
render method with function component element as 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 object arguments with data that are accepted by function components to return a React element

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

Define a new element with the function component and define the specified property to use 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

< button > { expression } < /button >

curly braces

17
Q

What is the purpose of state in React?

A

Data model for keeping track of values that change over time

18
Q

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

A

Pass events as props

i.e.
onClick = {this.handleClick}

19
Q

What are controlled components?

A

With a controlled component, the input’s value is always driven by the React state

20
Q

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

A

onChange Event Handler and value property

21
Q

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

A

map method

22
Q

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

A
23
Q

When does React call a component’s componentDidMount method?

A

componentDidMount() is invoked immediately after a component is mounted (inserted into the tree)

24
Q

Name three React.Component lifecycle methods.

A

componentDidCatch( )
componentDidUpdate( )
componentDidMount( )

25
Q

How do you pass data to a child component?

A