React Flashcards

1
Q

What is React?

A

JS library for building UI
For front-end

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

What is a React element?

A

basic building block in a react application - an object representation of a virtual DOM node

It’s just an object

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

by calling ReactDOM. and calling render()

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

What is Babel?

A

Toolchain used to convert ECMAScript 2015+ code into a backwards-compatible version of JS in current and older browsers or environments

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

What is a Plug-in?

A

it gives extended functionality

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

What is a Webpack loader?

A

transformations that are applied to the source code of a module
Webpack loaders follow thru import/export and convert the syntax and style as it goes through it

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

install ‘babel-loader’ to the loader

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

What is JSX?

A

a syntax extension to JS
allows us to write declarative JS like writing html within js

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

Because it works with React object to because we are actually using react ReactDom.createElement()

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-loader and the babel plugins

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

What is a React component?

A

independent and reusable bits of code
They serve the same purpose as JS functions but work in isolation and return HTML

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

a function that returns an HTML-like syntax

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

type of object where the value of attributes of a tag is stored
props –> properties

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

add them to the JSX

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

use curly brace like {element.text}

17
Q

How do you create a “class” component in React?

A

use the keyword class and className and extends keyword and React Object and component property { render() }

18
Q

How do you access props in a class component?

A

render() function

19
Q

What is the purpose of the state in React?

A

to contain data about the component

store property value that belongs to the component

gives localized data for that specific component and the data that it should be returning

20
Q

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

A

add an attribute to the React element

21
Q

What are controlled components?

A

form’s data is handled by the component’s state
it takes its current value thru props and makes changes thru callbacks like onClick and onChange

Controlled by React and making it a single source of truth
React controls what happens in that form on subsequent user input

22
Q

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

A

value and onChange

23
Q

What Array method is commonly used to create a list of React elements?

A

map() array method – returns an array

24
Q

What is the best value to use as a “key” prop when rendering lists?

A

to use a string that uniquely identifies a list item among its siblings