React Flashcards

1
Q

What is JSX?

A

a syntax extension to JS allow us to write declarative inside js files (such as HTML).

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

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

A

because JSX is part of React library

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

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

A

by installing devDependencies -> @babel/plugin-transform-react-jsx

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

What is a React component?

A

JS functions

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

How do you define a function component in React?

A

function function_name (props as parameter) {
return JSX element[s]
}

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

How do you mount a component to the DOM?

A

by calling render of root object and passing in JSX elements/function components

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

What are props in React?

A

Parameters for React function component
{ object }

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

How do you pass props to a component?

A

through attribute keys and value ->

<Function></Function>

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

How do you write JavaScript expressions in JSX?

A

{ JS expression }

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

How do you create “class” component in React?

A

class className extends React.Component {
render() {
return //codes
}
//other codes
}

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

How do you access props in a class component?

A

using this.props.//

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

What is the purpose of state in React?

A

object that hold information that influences the output render(), state is managed within the component

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

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

A

by binding it. this.EventHandler.bind(this)
also add it as attribute onto the JSX element[s]

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

What are controlled components?

A

an element whose value is controlled by react

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

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

A

value & onChange

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

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

A

.map()

17
Q

What does express.static() return?

A

[middleware] return static files (images, css files, JS files, …)

18
Q

What is the local __dirname variable in a Node.js module?

A

The directory name of the current module. This is the same as the path.dirname() of the __filename.

19
Q

What does the join() method of Node’s path module do?

A

join all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path

20
Q

When does React call a component’s componentDidMount method?

A

is invoked (called) immediately after a component is mounted (inserted into the tree).

21
Q

Name three React.Component lifecycle methods.

A

Render(), Constructor(), ComponentDidMount()

22
Q

How do you pass data to a child component?

A

using props