React.js Flashcards

1
Q

What is React?

A

javascript library for creating user interaces

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

What is a React element?

A

object but not DOM

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

How do you mount a React element to the DOM?

A

root.render()

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

What is Babel?

A

toolchain that convert new javascript to old javascript

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

What is a Plug-in?

A

software component that adds specific feature to program

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

What is a Webpack loader?

A

transformation of files from different language to javascript

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

What is JSX?

A

syntax extension to javascript

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

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

A

react element is actually being called

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

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

A

‘@babel/plugin-transfomr-react-jsx’
ex: const element = <h1> ____ </h1>
*always need closing tag for react element; anything goes between tags called props.children
read as react element type h1 for react element

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

What is a React component?

A

function or class that returns react element and could be appear on the screen

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

How do you define a function component in React?

A

function name with CAPITAL first letter

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

How do you mount a component to the DOM?

A

root.render()

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

What are props in React?

A

object that passed as argument in function/ property in class situation

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

How do you pass props to a component?

A
ex. 
function CustomButton(props) {
  return Click Me! {props.name};
}
(if not string) {ex: #} is needed
root.render();
if class, this.props.
class CustomButton extends React.Component {
  render() {
    return {this.props.text};
  }}
const element = (
  <div>

</div>
);

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

How do you write JavaScript expressions in JSX?

A

{}

17
Q

How do you create “class” component in React?

A
class \_\_\_\_ extends React.Component{
render().{
return
}
}
*render() is required*
18
Q

How do you access props in a class component?

A

this.props.____

19
Q

What is the purpose of state in React?

A

keep track of value that change over time

20
Q

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

A

call the event as property and set the fallback function as value
ex.

21
Q

What are controlled components?

A

input form element whose value is controlled by react

22
Q

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

A

key (must be unique) -> id or index
onChange -> value changes when event.target.value changes
ex. this.setState({value: event.target.value})