React Flashcards

1
Q

What is React?

A

a JavaScript framework 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

a plain JavaScript object that is the smallest building block of a React app

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, [callback])

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

What is Babel?

A

a JavaScript compiler mainly used to convert ES6 code into a backward-compatible version of JavaScript

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

What is a Plug-in?

A

a software component that adds a specific feature to and enables customization for 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

a transformations (plug-in) that is 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

install babel-loader as a devDependency

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

What is JSX?

A

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

the createElement( ) method of the React object is called to produce React “elements”

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

install @babel/plugin-transform-react-jsx as a devDependency and add the plug-in to webpack.config.js

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 function that returns a React element

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 keyword, capital functionName with props in parentheses, then the code block that 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(ReactElement, container)

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

What’s the difference between a library and a framework?

A

inversion of control - a framework is a type of library that calls your code

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

What are props in React?

A

properties contained in an object that are used to pass data into a React component

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

How do you pass props to a component?

A

prop key=”value” pairs

17
Q

How do you write JavaScript expressions in JSX?

A

enclosed in curly braces

18
Q

How do you create “class” component in React?

A

class keyword w/ capital className, followed by extends React.Component; must define a render( ) method

19
Q

How do you access props in a class component?

A

the props property of this object (this.props)

20
Q

What is the purpose of state in React?

A

keep track of values that change over time

21
Q

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

A

the event handler is a method on the class and is passed as a prop in the render( ) method

22
Q

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

23
Q

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

A

a string that uniquely identifies a list item among its siblings

24
Q

What is the virtual DOM?

A

lifecycle of React elements - the render( ) method of the component gets called once and outputs one React element; if the state updates, it outputs a slightly different React element, and then the React virtual DOM compares the diff and makes small surgical patches to the real DOM in the browser

25
What are controlled components?
input form React elements that receive their value via state and have a change-handler that updates the state
26
What two props must you pass to an input for it to be "controlled"?
value, onChange