React Flashcards

1
Q

What is React?

A

Framework to create interactive UIs in a web browser

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

What is a React element?

A

a plain object describing a component instance or DOM node and its desired properties., react component

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

Render method
DOMElementHere.render(elementhere)

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

What is JSX?

A

a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript file

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

React elements will be undefined

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 reads the JSX and converts to JavaScript while webpack loads them module to read it.
plugin for babel loader

Using the appropriate converter with the proper 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

JavaScript function that you can use markup with
reusuable code such as js functions

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

Export default function functName() {
Return (

<div>
)
}

name is wit capitalized first letter and return JSX
</div>

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

Mount means render so that it displays, using render method

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

What are props in React?

A

standardized way to pass arguments to a function

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

inside angle brackets, property = value

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

in curly brackets

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

What is the purpose of state in React?

A

re-renders the component to the browser

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

What is a React Effect?

A

Function that will execute after the render

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

When should you use an Effect and when should you not use an Effect?

A

Effects are typically used to “step out” of your React code and synchronize with some external system

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

When do Effects run?

A

After it mounts/render, when a dependency changes

17
Q

What function is used to declare an Effect?

A

useEffect(callback, dependencies);

18
Q

What are Effect dependencies and how do you declare them?

A

tell React to skip unnecessarily re-running the Effect by specifying an array of dependencies, In an array

19
Q

How do you clean up from an Effect?

A

if return a funct from useEffect, , clear up the interval

20
Q

Why would you want to clean up from an Effect?

A

returning a function from effect callback

21
Q

When does the clean up function run?

A

before effect runs next time, and during unmount