react-function-components Flashcards

1
Q

What is a React component?

A

A React component is like a JavaScript function. 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

The simplest way to define a component in React is to write a JavaScript function; and capitalize the first letter of the name.

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

Defining a “root” using something like “ReactDOM.createRoot(document.getElementById(‘root’)”, assigning a variable the component (i.e. “const element = < Welcome name = “Sara”; / >”), and using “root.render(element);”.

*Note: spaces added in the component example because Brainscape reads HTML code

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