React Flashcards

1
Q

What is Webpack?

A

A bundler for your JavaScript files, their dependencies and other assets of your application (ex CSS, images, html)

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

How do you add a devDependency to a package?

A

npm install –save-dev

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

What is an NPM script?

A

CLI commands you can add to the scripts section/property of package.json. You can give the commands a name and run them using
npm run

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

How do you execute Webpack with npm run?

A

Depends on what name you give the npm script

Usually it’s npm run build

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

How are ES Modules different from CommonJS modules?

A

ES modules are used on the front-end when working with javascript running on the browser;

Common js modules and require statements and module.exports are used with Node on the backend

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

What kind of modules can Webpack support?

A

Most of them??

Webpack supports the following module types natively:

ECMAScript modules
CommonJS modules
AMD modules
Assets
WebAssembly modules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is React?

A

Javascript library for creating user interfaces;

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

What is a React element?

A

jsx that describes a piece of UI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
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
10
Q

What is a React component?

A

A JavaScript function or class 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
11
Q

How do you define a function component in React?

A
function ComponentName(props) {
  return < html >Hello, {props.name}< html >;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are props in React?

A

Arguments/inputs to a react component, they are accessed as properties on an object called props

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

Through the component’s attributes

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

Enclosed in {}

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

extend the React.Component base class; give it a render function that returns jsx

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

How do you access props in a class component?

A

this.props - meaning props is an instance property on the class, state is as well

17
Q

What is the purpose of state in React?

A

to encapsulate data locally to component

”State is similar to props, but it is private and fully controlled by the component.”

18
Q

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

A

Use use the function’s bind method to set its this value, then pass as an attribute like any other prop

or wrap event handler call arrow function