React Flashcards

1
Q

What is Webpack?

A

It’s a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.

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 add –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

They are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application. Scripts are stored in a project’s package.

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

npm 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 - direct support for asynchronous loading and configurable modeule loading
javascript

commonJS - designed for synchronous loading
nodeJS

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

ECMAScript
CommonJs
AMD modules

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

What is React?

A

A JavaScript library for building 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

an object

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

root.render(element)

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

What is a Plug-in?

A

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
12
Q

What is a Webpack loader?

A

Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or “load” them. Thus, loaders are kind of like “tasks” in other build tools and provide a powerful way to handle front-end build steps. Loaders can transform files from a different language (like TypeScript) to JavaScript or load inline images as data URLs. Loaders even allow you to do things like import CSS files directly from your JavaScript modules!

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

How can you make Babel and Webpack work together?

A

babel-loader

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

What is JSX?

A

syntax extension to javascript

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

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

A

Since JSX compiles into calls to React.createElement, the React library must also always be in scope from your JSX code

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

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

A

transform react jsx plugin

17
Q

What is a React component?

A

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

18
Q

How do you define a function component in React?

A
function keyword name, params
return jsx
19
Q

How do you mount a component to the DOM?

A

root.render

20
Q

What are props in React?

A

objects

properties, passing data from one component to another

21
Q

How do you pass props to a component?

A

you write ButtonClick type=”asfd” in angled brackets

22
Q

How do you write JavaScript expressions in JSX?

A

surround it with curly braces

23
Q

How do you create “class” component in React?

A
class Classname extends React.Component {
render()
}
24
Q

How do you access props in a class component?

A

with this

25
Q

What is the purpose of state in React?

A

The state is a built-in React object that is used to contain data or information about the component
Keep track of values that change over time

26
Q

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

A

put it in when the react element is rendered

button onClick={this.handleClick}Click Me!/button;

27
Q

What are controlled components?

A

An input form element whose value is controlled by React in this way is called a “controlled component”.

28
Q

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

A

value and onchange

29
Q

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

A

map

30
Q

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

A

id (anything unique)

pokedex.map((pokemon, index) => function