react Flashcards

1
Q

what is react

A

react is a javascript framework for interactive UI

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

What is a React element?

A

an element made in react that returns an html element

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

ReactDOM.createRoot( queried element )

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

What is JSX?

A

syntax extension of javascript, produces react elements

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

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

A

jsx creates react elements so you need the react object to read the jsx

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

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

A

babel loader

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

What is a React component?

A

basically a javascript function that makes react elements

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

What is a React component?

A

basically a javascript function that makes react elements

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

How do you define a function component in React?

A

function definition like javascript that returns a react object

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

How do you mount a component 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 are props in React?

A

properties, javascript expressions

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

How do you pass props to a component?

A

as a react function attribute

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

How do you write JavaScript expressions in JSX?

A

inside { } curly braces

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

How do you create “class” component in React?

A

class ClassName extends React.Components {

}

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

How do you access props in a class component?

A

this.props.property

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

What is the purpose of state in React?

A

keep track of a certain state over time of a component

16
Q

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

A

prop attribute = { event handler }

17
Q

What are controlled components?

A

react element whose value is controlled by react

value of the element is stored in a state

18
Q

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

A

value and onChange

19
Q

What Array method is commonly used to create a list of React elements?
What is the best value to use as a “key” prop when rendering lists?

A

Array.map( )

an id value

20
Q

When does React call a component’s componentDidMount method?

A

at definition time

after the first sucesssufl render

21
Q

Name three React.Component lifecycle methods.

A

componentDIdMount / unmount
constructor
render
didupdate

22
Q

How do you pass data to a child component?

A

props