react-function-components Flashcards

1
Q

What is a React component?

A

A React component is like each small pieces of the user interface that can be re-used and processed separately.

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
You can write a JavaScript function, the first letter of the component name has to be capitalized.
function keyword, component name, paramter props, and the element you want to return in the return statement. ( a JSX 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

with the ReactDOM.render(), first argument is the element, second argument is the container.
example:
ReactDOM.render(, document.getElementById(‘root’);
*Welcome is a user-defined component name.

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