React/Webpack Flashcards

(31 cards)

1
Q

What is React?

A

A javascript library for building interfaces

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

What is a React element?

A

An HTML element created using React syntax, and the smallest building block of a React app

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

How do you mount a React element to the DOM?

A

ReactDOM.render() method

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

What is Babel?

A

A JS compiler that comverts ES code into a backwards compatible version of JS

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

What is a Webpack loader?

A

They preprocess files as they are imported, allowing for frontend build steps to be handled

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

How can you make Babel and Webpack work together?

A

by installing the babel loader as a dev dependency when using Webpack

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

What is JSX?

A

A syntax extension that allows you to create React elements using HTML-like markup

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

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

A

JSX creates React elements, which require React in order to be built

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

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

You install the transform-react-jsx npm plugin as a dev dependency along with the babel loader and webpack

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

What is a React component?

A

A function that accepts inputs called props and returns a React element

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

How do you define a function component in React?

A

using normal function definitions or es6 classes

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

How do you mount a component to the DOM?

A

use ReactDOM.render(), with function name and root css selector as parameters

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

What are props in React?

A

Properties that can be passed into a component

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

How do you pass props to a component?

A

Enclose the prop value in curly brackets and assign it to a property on the prop object of the component

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

How do you write JavaScript expressions in JSX?

A

Enclose the expression in curly braces

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

How do you create “class” component in React?

A
  • Use the class keyword, followed by function name, followed by extends keyword then React.Component
  • Next line: render()
  • Next line: return keyword, react element type, js expression with this. included
16
Q

How do you access props in a class component?

A

this.props.nameOfValue

17
Q

What is the purpose of state in React?

A

Allows you to store variables in a React component
Useful for values that can change over time or need to be updated

18
Q

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

A

bind the event to this in the class constructor function

19
Q

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

20
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, such as an id

21
Q

What are controlled components?

A

An input form element that is controlled by react in that it renders a form and also controls what happens in that form

22
Q

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

A

onChange and value

23
Q

When does React call a component’s componentDidMount method?

A

once the component is rendered

24
Name three React.Component lifecycle methods.
componentDidMount, componentDidUpdate, componentWillUnmount
25
How do you pass data to a child component?
assigning that data to props and passing the props to the child component
26
What is Webpack?
Webpack is a tool that lets you bundle javascript applications together
27
How do you add a devDependency to a package?
Use the --save-dev keyword when installing the npm package
28
What is an NPM script?
A piece of code that executes a task when run using node and is located in the package json file under scripts
29
How do you execute Webpack with npm run?
Npm run then the name of the script
30
What kind of modules can Webpack support?
o ES, CommonJS, AMD, Assets, webAssembly