REACT FUNCTION COMPONENTS Flashcards
1
Q
What is a React component?
A
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML.
2
Q
How do you define a function component in React?
A
function Name (prop) {
return (
whatever element{prop.whatever}
)
3
Q
How do you mount a component to the DOM?
A
const root = React.DOM (document.querySelector(‘#root’));
const whatever = <function>
root.render(whatever)</function>