react-function-components Flashcards
1
Q
What is a React component?
A
A function or a class the returns React elements. Reusable. Used for a chunk of UI.
2
Q
How do you define a function component in React?
A
By creating a function with a capital first letter that returns a React DOM element. In the return it is HTML that is converted to a React DOM element.
3
Q
How do you mount a component to the DOM?
A
- Query the page for root
- Call createRoot on ReactDOM object and give it the queried root
- Call render on root object and give it a component