React Flashcards

1
Q

What is React?

A

a JavaScript library for creating user interfaces.

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

What is a React element?

A

a plain object describing a component instance of DOM node and its desired properties.

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 using ReactDOM.render(element, container[,callback] )

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

What is Babel?

A

a JavaScript compiler, a toolchain that is mainly used to convert ECMA Script 2015 code into a backwards-compatible version of JavaScript in current and older browser environments.

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

What is a Plug-in?

A

a software component that adds a specific feature to an existing computer program.it enables customization

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

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 using the babel loader. babel compiles js and webpack bundles js. babel loader bridges both of them together

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

What is JSX?

A

it is a syntax extension to JS that produces React “elements”. Although React doest require using JSX, most people find it helpful as a visual aid when working with UI inside the JS code.

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

in order to to have Babel transform JSX into valid JS.

for React.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

with the babel-loader. Babel then has plugin that transforms react-jsx to valid JS back to webpack.

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

What is a React component?

A
components are like JS functions, they accept arbitrary inputs(called "props") and return React elements describing what should appear on the screen.
can also be a JS class and has to return 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

functions have to be capitalized

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

with ReactDOM.render( ),

you must put the < /> (ankle brackets)

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

What are props in React?

A

stands for properties and is used for passing data from one component to another. Data with props are passed in a uni-directional flow(one way from parent to child). Props are objects

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

by defining custom HTML attributes to which you assign your data with JSX.They are actually key value pairs

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

surround the code in curly brackets.

17
Q

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

A

the map method

18
Q

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

A

value that’s unique to each list items

19
Q

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

A

by extending from React.Component, then defining render( ) method in its subclass

20
Q

How do you access props in a class component?

A

with this. object

21
Q

What is the purpose of state in React?

A

It’s a built-in object where you store property values that belong to the component. When the state object changes, the component re-renders.
To keep track of data that changes is the purpose of state.

22
Q

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

A

by using bind( ) method. example: this.handleClick.bind(this)

23
Q

What are the controlled components?

A

An input form element whose value is controlled by React. React controls what happens in that form on subsequent user input.

24
Q

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

A

value which takes the current state as its value and onChange props