React Docs Flashcards

1
Q

What is the command to create a new project using NPM?

A

npm init -y

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

What does Babel do?

A

It accepts ES6 and React code as input, and creates regular JavaScript as output.

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

What is the process of converting ES6 source code to old-school JS called?

A

Transpiling.

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

What does Webpack do?

A

it is a tool that converts all our source code into one finished app ready to ship to users. It is controlled by the webpack.config.js file.

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

What npm package allows you to run a webpack dev server locally?

A

webpack-dev-server

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

What does the “export” keyword mean?

A

It means that the component is being exposed to the rest of the app to use.

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

What does the “default” keyword mean?

A

It means its the only thing this class will expose.

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

What is hot loading?

A

It’s a way to update the code in a running application without restarting or resetting the application state.

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

What does ReactDOM do?

A

It imports the React tools required to render to the DOM.

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

What two parameters does ReactDOM.render take?

A

Some JSX to render and where to render it to.

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

How does JSX know what means?

A

From the name it is imported under.

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

What is JSX?

A

It is a syntax extension to JavaScript. It produces React elements.

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

How can you embed any JavaScript expression in JSX?

A

Wrap it in curly braces.

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

Why is it recommended that you wrap multi-line JSX in parentheses?

A

To avoid the pitfalls of automatic semicolon insertion.

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

What do JSX expressions become after compilation?

A

Regular JavaScript objects.

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

Why shouldn’t you put quotes around curly braces when embedding a JS expression in a JSX attribute?

A

JSX will treat the attribute as a string literal rather than an expression.

17
Q

Does ReactDOM use camelCase property naming conventions in JSX, or HTML attribute names?

A

camelCase. Example- HTML class is className in JSX. This is because JSX is closer to JavaScript than HTML.

18
Q

How does JSX prevent XSS (cross-site-scripting) attacks?

A

By default, React DOM escapes any values embedded in JSX before rendering them. Thus it ensures that you can never inject anything that’s not explicitly written in your application. Everything is converted to a string before being rendered.

19
Q

What does Babel compile JSX down to?

A

React.createElement() calls.

20
Q

What syntax scheme should you search for in a code editor to ensure that both ES6 and JSX code is properly highlighted?

A

Babel syntax scheme.

21
Q

What are JSX objects called?

A

React elements.

22
Q

What are the smallest building blocks of React apps?

A

elements.

23
Q

What takes care of updating the DOM to match the react elements?

A

React DOM

24
Q

How are React elements different from browser DOM elements?

A

They are plain objects, and are cheap to create.

25
Q

Why is a “root” DOM node called that?

A

If everything inside it will be managed by React DOM. Applications built with just React usually have a single root DOM node, but if React is being integrated into an existing app, it may have many isolated root DOM nodes.

26
Q

How do you render a React element into a root DOM node?

A

Pass both to ReactDOM.render()

27
Q

Are React elements immutable?

A

Yes. Once you create an element, you can’t change its children or attributes.

28
Q

How does React only update what’s necessary?

A

React DOM compares the element and its children to the previous one, and only applies the DOM updates necessary to bring the DOM to the desired state.

29
Q

What is the purpose of having components?

A

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

30
Q

How are React components conceptually like JavaScript functions?

A

They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

31
Q

When would a component be called “functional”?

A

When it is literally a JavaScript function, accepting a “props” object argument and returning a React element.

32
Q

How can you define a component other than a functional component?

A

By using an ES6 class.

33
Q

What can elements represent other than DOM components?

A

user-defined components.