React Flashcards

1
Q

What is React?

A

a js library for creating user interfaces in a more intuative way.

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

What is a React element?

A

it is an object that represents a DOM

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

You mount it using render, with the element name and then a container

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

What is Babel?

A

Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript 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

software component that adds a specific feature to an existing computer program

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

What is a Webpack loader?

A

Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or “load” them. Thus, loaders are kind of like “tasks” in other build tools and provide a powerful way to handle front-end build steps. Loaders can transform files from a different language (like TypeScript) to JavaScript or load inline images as data URLs.

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

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

What is JSX?

A

It is called JSX, and it is a syntax extension to JavaScript. We recommend using it with React to describe what the UI should look like. JSX may remind you of a template language, but it comes with the full power of JavaScript.

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

Since it uses the react-createElement syntax, it needs to be imported

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/plugin-transform-react-jsx

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

What is a React Component?

A

It is a function that can be used like a reusable code it can also be a class component: it accepts a single”props” object argument with data and returns a React element.

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

This function is a valid React component because it accepts a single “props” (which stands for properties) object argument with data and returns a React element. We call such components “function components” because they are literally JavaScript functions.

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

Render method is how you mount a component

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

What are props in React?

A

You can pass any JavaScript expression as a prop, by surrounding it with {}. For example, in this JSX:
(How we pass data into components)

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
function CustomButton(props) {
  return (
    {props.text}
  );
}
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

{} using template literals and putting the expression or variable name in them

17
Q

How do you create “class” component in React?

A

class (NAME) extends React.Component {

render() {}
}

18
Q

How do you access props in a class component?

A

You need to use template literals and use this keyword

19
Q

What is the purpose of state in React?

A

Setting a state is so that the the interface knows what to put on the screen depending allowing for conditional rendering

20
Q

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

A

You set it as an attribute where the event handler is the set value

21
Q

When does React call a component’s componentDidMount method?

A

It is called after render method is called for the first time

22
Q

Name three React.Component lifecycle methods.

A

Render, componentDidmount, componentDidUpdate, constructor, component will unmount

23
Q

How do you pass data to a child component?

A

Via props