React Components vs. Component Instances vs. React Elements Flashcards

These flashcards should help you understand the concepts of React components, component instances, React elements, and the relationship between them.

1
Q

What is the difference between React components, component instances, and React elements?

A
  • React Components: Components are generic descriptions or blueprints for pieces of a user interface. They are written as JavaScript functions that return React elements.
  • Component Instances: Component instances are the actual manifestations of components in a React application. They are created by React each time a component is used in the code and hold their own state, props, and lifecycle.
  • React Elements: React elements are JavaScript objects that represent the output of using a component in the code. They contain information needed to create DOM elements for a component instance.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you think of a React component in terms of its role in the user interface?

A

A React component can be thought of as a blueprint or template for a piece of the user interface. It describes how the UI should look and behave but doesn’t represent an actual instance of that UI.

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

How are component instances created in React?

A

Component instances are created by React each time a component is used in the code. React calls the component function to create these instances, and each instance holds its own state, props, and lifecycle.

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

What role do React elements play in the React application’s structure?

A

React elements are intermediate objects that represent the output of using a component. They contain information needed to create DOM elements for rendering, and they exist within the React application but are not the final DOM elements themselves.

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

When does a React element get converted into actual DOM elements?

A

A React element gets converted into actual DOM elements during the final rendering step when React paints the elements onto the screen in the browser.

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