React Flashcards

1
Q

What are the features of React?

A

JSX: syntax extension for JS, can write HTML in same file as JS
Components: splits application into independent reusable parts
Virtual DOM: when state changes virtual DOM only changes the object in the real DOM instead of updating all the objects

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

Can web browsers read JSX directly?

A

No, they are built to only read regular JS objects which JSX is not.

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

What is the virtual DOM?

A

A lightweight representation of the real DOM stored in memory, when the state of an object changes, the virtual DOM changes only that object in the real DOM

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

What is the difference between the ES6 and ES5 standards?

A

components and functions
exports vs export
require vs import

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

What is an event in React?

A

An action the user or system triggers such as a mouse click, pressing a button

ex. onClick is the event

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

What is a synthetic event?

A

An example is preventDefault()

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

Explain how lists work in React.

A

the traversal of lists is done using the map() function

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

Why is there a need for using keys in Lists?

A

a key is a unique identifier and is used to see which items have changed from the list and determines which items need to be re-rendered.

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

What are forms in React?

A

Forms allow the user to interact with the application and enter the required information whenever needed.

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

How do you create forms in React?

A

set useState for each input, use onChange to set the state of specific field, create a handleSubmit to for when the user clicks a submit button.

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

How do you write comments in React?

A

For single line #

For multiple lines {/* */}

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

What is an arrow function and how is it used in React?

A

shorter way of writing a function and there is no need to bind this inside the constructor.

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

What are components in React?

A

A piece of the user interface. Components splits the interface into independent reusable parts that can be processed separately.

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

Function components vs Class components

A

Functional: AKA stateless components, have no state of their own and only contain render methods

Class: AKA stateful components, can hold and manage their own state and have a separate render method to return JSX.

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

What is the use of the render() method in React?

A

Returns the HTML which is displayed in the component

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

What is state in React?

A

a built in React object that is used to contain data or information about the component. When the state changes the component re-renders

17
Q

What are props in React?

A

Provide a way to pass data from one component to another, the same way arguments are passed to a function.

18
Q

Difference between state and props?

A

State: holds information about the components

Props: allows to pass data from one component to other components as arguments.

19
Q

What is a higher-order component in React?

A

Acts as a container for other components, helps to keep components simple and enables re-usability.

20
Q

What is Redux?

A

an open-source JS library used to manage the application state.

21
Q

What are the components of Redux?

A

Store: holds the state of the application

Action: the source information for the store

Reducer: specifies how the applications state changes in response to actions sent to the store

22
Q

What is React Router?

A

A routing library built on top of React, where you can define the routes of an application

23
Q

What are React hooks?

A

it allows you to use state and other react features without a class, can extract stateful logic from a component

24
Q

What does useEffect do?

A

tells the react component to do something after re-render

25
Q

What does useState do?

A

allows us to track state in a functional component

26
Q

what does useMemo do?

A

keeps resource intensive functions from running needlessly

27
Q

React Hook rules

A

could only be called inside functional components
cannot be conditional
can only be called at the top level of a component