React 230327 Flashcards
What is React?
What is a React element?
a component (see what component is)
How do you mount a React element to the DOM?
this means to attach/insert a component into the dom tree
you mount by calling:
ReactDOM.render(foo, domContainer);
What is JSX?
a way to write html in react
How does React use JSX to render components?
What is a React component?
a JavaScript function that you can sprinkle with markup
How do you define a component in React?
In the return statement of a function whose name is capitalized, and which can be exported
How do you mount a component to the DOM (or “render” a component)?
What are props in React?
a way to pass info using what in html is like an attribute
How do you use props in a component?
How do you pass props to a component?
How do you write JavaScript expressions in JSX?
within curly braces
What are hooks in React?
a function starting with “use” then an uppercase letter,
e.g. useState
What are the “Rules of Hooks”? (if necessary, re-read the “Pitfall” box in State)
-declare at top
-don’t use inside conditionals/loops
-use “use”
-can only be called in react components and other hooks
What is the purpose of state in React?
it holds the data between function calls