React Flashcards

1
Q

What is React?

A

a front-end JavaScript library for building interactive UIs

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

What is a React element?

A

an object which is a visible building block of a React app

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

ReactDOM.render(elementToRender, container)

ex. ReactDOM.render(h1Element, document.getElementById(‘root’))

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

What is JSX?

A

a syntax extension to JavaScript which produces HTML-like React elements

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 compiles into calls to React.createElement()

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

install babel plugin-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 function or class which 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
function keyword, capitalized name, (props), { return  }
ex. function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
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(element, container)

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

library vs framework

A

library: you are in charge of the flow of the application, tell the library what to do (jQuery, React- concerned with rendering UI)

framework: framework is in charge of flow, it calls the code you plugged in as needed
(Bootstrap)

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

What are props in React?

A

an object, used to pass data into React components

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

How do you pass props to a component?

A

add props to element as a key/value pair

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

How do you write JavaScript expressions in JSX?

A

wrap in curly braces { expression }

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

How do you create “class” component in React?

A

‘class’ keyword + name, extends React.Component, render() { return Reactelement }

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

How do you access props in a class component?

A

this.props

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

What is the purpose of state in React?

A
  • keep track of status of data that will change over time

- similar to props, but private and fully controlled by the component

17
Q

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

A
  • as a prop
  • event, assignment operator, { }
    ex. onClick={this.doSomething}
18
Q

react virtual dom

A

if state changes, it only changes what needs to be changed, instead of reloading entire dom (‘You tell React what state you want the UI to be in, and it makes sure the DOM matches that state’)