React.js Flashcards

1
Q

What is React?

A

React is a JavaScript library and is intended to provide a simpler way to do ui

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

What is a React element?

A

smallest building block of React apps; they are plain objects and cheap to create

React Dom takes care of updating the DOM to match the React elements

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

use ReactDOM.render to mount a React element to a dom element

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

What is JSX?

A

Syntactical sugar for react

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 is not really JS but Syntactical sugar for react

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 JS?

A

install the babel plugin for transform react JSX

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

What is a React component?

A

a class or function that returns 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

use class or function and use jsx

function Welcome(props) {
  return jsxtag;
}

or

class Welcome extends React.Component{
  render() {
    return someTag
  }
}
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

ReactDOM.render

OR if you use an ES6 class to define a component you can use extends React.Component{
  render() {
    return someTag
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are props in React?

A

propertiesm they are objects

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 parameters

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

use 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

You use render()

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

you need to specify “this”

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

to determine how a class should exist as

state is a data model over time

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

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

A

via a prop

17
Q

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

A

array.prototype.map

18
Q

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

A

An id from your data

19
Q

What are controlled components?

A

jsx elements with props: value, onChange

20
Q

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

A

value, onChange

21
Q

why submit and not click

A

submit tells the form to submit itself

22
Q

When does React call a component’s componentDidMount Method?

A

When the component mounts

23
Q

Name three Ract.Component lifecycle methods

A

constructor, render, componentDidMount, componentWillUnmount

24
Q

How do you pass data to a child component?

A

use props