React Flashcards
What is React?
A JavaScript library for building user interfaces
What is a React element?
An object
What is JSX?
Syntatical sugar that allows HTML elements to be easily created
Why must the React object be imported when authoring JSX in a module?
b/c React.createElement is being done behind the scenes
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
use @babel/react-jsx
How do you define a function component in React?
Using uppercase, returns a React Element
How do you mount a component to the DOM?
ReactDOM.render
What is a React component?
JS like functions that let you split the UI into independent, reusable pieces
How do you pass props to a component?
add it as a parameter in function, within component call name={value}
How do you write JavaScript expressions in JSX?
inside curly braces
What are props in React?
An object
What Array method is commonly used to create a list of React elements?
Array.map()
What is the best value to use as a “key” prop when rendering lists?
An object’s id, something that will never repeat or change
How do you create “class” component in React?
Must use uppercase, extends React.Component, MUST have render method in there where you return the React elements
How do you access props in a class component?
this.props