React-function-components Flashcards

1
Q

What is a React component?

A

a chunk of code that can be separated buy their functionality. Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

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

How do you define a function component in React?

A

it accepts a single “props” (which stands for properties) object argument with data and returns a React element.

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you mount a component to the DOM?

A

ReactDOM.render()

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