REACT Flashcards

1
Q

What is React?

A

JS 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

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

query the dom for the root

reactDOM.render(element, container, callback)

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 backwards 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

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

transformation s that are applied to the source code of a module. They allow you to pre-process files as you import and “load” them.

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

Install babel Loader

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

What is JSX?

A

Syntax extension of JavaScript, allows us to write HTML in react, makes it easier to write and add HTML in React. Provides a visual aid when working with UI inside the javascript code.

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 complies into calls to React.createElement, react library must always be in scope from your JSX code.

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

Use babel loader

Install babel/plugin-transform-react-jsx

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

What is a React Component?

A

Independent, reusable bits of code, serves the same purpose of Javascript functions, but works in isolation and returns HTML

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

Function functionName(props){ return react element}

Class functionName extends React.Component {render() { return 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

Query the DOM for the root

Assign the component to a const variable, (
root.render(variableName)

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

What are props in React?

A

Properties in react and used for passing data from one component to another

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

Prop.name

propertyName = {}
propertyName = 'string'
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 them with curly braces

17
Q

How do you create “class” component in REACT?

A

class CLASSNAME extends React.Component {
render()
}

18
Q

How do you access props in a class component?

A

This object

19
Q

What is the purpose of state in React?

A

keep track of values that will change over time

20
Q

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

A

As a prop , whatever event = {this.method}

21
Q

What are controlled components?

A

Input value controlled by React that renders a form and also controls what happens

22
Q

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

A

Value and onChange

23
Q

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

24
Q

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

A

Use IDs from your data as keys, when you dont have stable IDs, you may use the item index as a key as a last resort.

25
When does React call a component's componentDidMount method?
After render, after react updates DOM and refs and before updating
26
Name three React.Component lifecycle methods.
componentDidMount(), componentDidUpdate(), componentWillUnmount(), constructor(), render()
27
How do you pass data to a child component?
props