React Flashcards

1
Q

What are props in React?

A

props are arguments that are passed into react components

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

How do you pass props to a component?

A

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

How do you write JavaScript expressions in JSX?

A

by using {}

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

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

By adding the @babel/plugin-transform-react-jsx to babel loader.

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

because JSX is an extension of React. JSX compiles into react. Specifically React.createElement();

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

What is JSX?

A

JSX is a syntax extension for describing what a UI should look like in React.

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

By installing the babel loader and add it as a plugin to Webpack in a webpack config file.

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

What is a Webpack loader?

A

Loaders are transformations that are applied to the source code of a module.

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

What is a Plug-in?

A

A software component that adds a specific feature to an already existing program

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

What is Babel?

A

Babel is a toolchain that is mainly used for converting ECMAScript 2015+ code into a backwards compatible version of JavaScript

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

How do you mount a React element to the DOM?

A

By calling render method the the ReactDom object and passing it two arguments, the elements and the root DOM node.

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

What is a React element?

A

A React element is a plain object that the ReactDOM translates into a DOM object

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

What is React?

A

React is a JavaScript framework for building user interfaces

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

What kind of modules can Webpack support?

A

ECMAScript, CommonJS, and AMD modules

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

How do you execute Webpack with npm run?

A

by running the npm run build command. build is an npm script that bundles the modules into a main.js file.

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

What is an NPM script?

A

A script in the package .json file that is used to automate repetitive tasks.

17
Q

How do you add a devDependency to a package?

A

By including the –save-dev command when installing an npm package.

18
Q

What is Webpack?

A

webpack is a static module bundler for modern JavaScript applications.

19
Q

How do you create “class” component in React?

A

class keyword, class name, extend keyword, React.components, and then declaration block.

20
Q

How do you access props in a class component?

A

this.props

21
Q

What is the purpose of state in React?

A

State is like our data model for react elements. It sets an initial value and that value cane be changed at a later time, and react will then render the element based on its current condition

22
Q

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

A

By adding it as a prop

23
Q

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

A

map method

24
Q

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

A

A string that uniquely identifies a list item among its siblings.

25
Q

What are controlled components?

A

A controlled component is a form component who’s state is managed by react.

26
Q

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

A

onChange and onSubmit

27
Q

When does React call a component’s componentDidMount method?

A

After it runs the render() method

28
Q

Name three React.Component lifecycle methods.

A

componentDidMount, componentDidUpdate, componentWillUnwmount

29
Q

How do you pass data to a child component?

A

via props