React ?'s Flashcards

1
Q

React uses virtual DOM, what is it?

A

it updates the dom faster, updates the jsx elements if needed, manipulation is very easy

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

What is React?

A

front end javascript library

follows component based approach

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

What are the features of React?

A

uses virtual dom, server side rendering

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

advantages or React?

A

increases app performance, used on client and server side, JSX makes code easy to read

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

disadvantages?

A

just a library, not a framework, library is very large

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

what is JSX?

A

JavaScript XML, combination of JS and HTML template syntax

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

What is the virtual dom?

A

a copy of the real dom. creates a node tree out of react components. It is re-rendered, and whatever has changes is what gets updated in the dom.

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

Why can’t browsers read JSX?

A

Need to transform JSX into a jS object using something like babel, then pass into browser.

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

ES5 v ES6?

A
var react = require('react')
import React from "react"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a component?

A

Components split up entire react UI into smaller separate pieces. Update without affecting rest of UI.

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

What is the purpose of Render?

A

Render is mandatory. Returns a single react component that is a representation of the native dom component.

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

What are props?

A

Read only components that are passed down from parent to child. Help maintain uni-directional data flow and used to render dynamic data.

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

What is state and how is it used?

A

source of data in react. Keep track of what changes in a component.

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

difference between state and props?

A

props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function).

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

how to update state?

A

this.setState or useState hook

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

what are arrow functions?

A

Used to bind context of components, useful when working with higher order functions

17
Q

What is the intial rendering phase? (react component lifecycle?)

A

Phase when the component is about to start its journey and make its way up to the DOM

18
Q

What is the updating phase (react component lifecycle?)

A

Once the component is added to DOM, it can potentially re redner only when a prop/state change occurs.

19
Q

What is unmounting phase? (react component lifecycle?)

A

This is the final phase of a component’s life cycle in which the component is destroyed and removed from the DOM

20
Q

Explain lifecycle methods in detail

A

componentWillMount() – Executed just before rendering takes place both on the client as well as server-side.
componentDidMount() – Executed on the client side only after the first render.
componentWillReceiveProps() – Invoked as soon as the props are received from the parent class and before another render is called.
shouldComponentUpdate() – Returns true or false value based on certain conditions. If you want your component to update, return true else return false. By default, it returns false.
componentWillUpdate() – Called just before rendering takes place in the DOM.
componentDidUpdate() – Called immediately after rendering takes place.
componentWillUnmount() – Called after the component is unmounted from the DOM. It is used to clear up the memory spaces.

21
Q

What is an Event in react?

A

events are triggered with user action, like click or submit.

22
Q

What are synthetic events in React?

A

combine behavior of different browsers into one API so they behave the same on different browsers

23
Q

What are refs?

A

provide a way to access dom notes or react elements created in render method.

24
Q

When should you use refs?

A

Managing text selection, media playback. Triggering animations, or adding third-party dom libraries.

25
How to modularize code?
Import and export statements
26
How to create a form?
Similar to how to create one in HTML. But need functions that account for change in values and add to state. ex) handleChange
27
Controlled v uncontrolled components?
controlled components do not maintain state, uncontrolled do. Controlled's data is by parent component, while uncontrolled is by DOM.
28
What are pure components?
Simplest components that can be written. Replace any component that has only a render, enhance simplicity of code.
29
What are the significance of keys?
Keys are used to identify unique dom elements. used when sorting through an array.