react Flashcards

1
Q

What is React?

A

A JavaScript library for building user interfaces or UI components

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 describing a component instance or DOM node and its desired properties

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

A

Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backward-compatible version of JavaScript in current and older browsers or environments.

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

What is a Plug-in?

A

is 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

by adding babel-loader to the list of modules in webpack.config

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

What is JSX?

A

A syntax extension of JavaScript.

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

Becasue the React library must be in scope from the JSX code in order to make calls to 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

by installing the react plugin

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

What is a React component?

A

a JavaScript class or function that optionally accepts inputs i.e. properties(props) and returns a React element that describes how a section of the UI (User Interface) should appear.

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

By writing a JavaScript function that accepts props as a single argument and returns a React element

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

ReactDOM.render( )

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

What are props in React?

A

They are objects used to pass data between react 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

ComponentName (props)

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

wrap it in { } curly braces

17
Q

How do you create “class” component in React?

A
class ComponentName extends React.Component {
    render ( ) {
         return....
        }
    }
18
Q

How do you access props in a class component?

A

this.props

19
Q

What is the purpose of state in React?

A

State is an object where property values belonging to a component are stored. When state changes, the componenet re-renders

20
Q

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

A

as an attribute

21
Q

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

A

map

22
Q

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

A

id or anything unique

23
Q

What are controlled components?

A

An input form element whose value is controlled by React. The React component that renders a form also controls what happens in that form on subsequent user input.

24
Q

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

A

value and onChange / handleSubmit and handleChange

25
Q

When does React call a component’s componentDidMount method?

A

immediately after a component is inserted into the DOM tree. after the render phase

26
Q

Name three React.Component lifecycle methods.

A

constructor, render, componentDidMount

27
Q

How do you pass data to a child component?

A

props