react-function-components Flashcards
What is a React component?
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 do you define a function component in React?
The simplest way to define a component in React is to write a JavaScript function; and capitalize the first letter of the name.
How do you mount a component to the DOM?
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