react Flashcards
what is react
react is a javascript framework for interactive UI
What is a React element?
an element made in react that returns an html element
How do you mount a React element to the DOM?
ReactDOM.createRoot( queried element )
What is JSX?
syntax extension of javascript, produces react elements
Why must the React object be imported when authoring JSX in a module?
jsx creates react elements so you need the react object to read the jsx
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
babel loader
What is a React component?
basically a javascript function that makes react elements
What is a React component?
basically a javascript function that makes react elements
How do you define a function component in React?
function definition like javascript that returns a react object
How do you mount a component to the DOM?
root.render(element)
What are props in React?
properties, javascript expressions
How do you pass props to a component?
as a react function attribute
How do you write JavaScript expressions in JSX?
inside { } curly braces
How do you create “class” component in React?
class ClassName extends React.Components {
}
How do you access props in a class component?
this.props.property
What is the purpose of state in React?
keep track of a certain state over time of a component
How to you pass an event handler to a React element?
prop attribute = { event handler }
What are controlled components?
react element whose value is controlled by react
value of the element is stored in a state
What two props must you pass to an input for it to be “controlled”?
value and onChange
What Array method is commonly used to create a list of React elements?
What is the best value to use as a “key” prop when rendering lists?
Array.map( )
an id value
When does React call a component’s componentDidMount method?
at definition time
after the first sucesssufl render
Name three React.Component lifecycle methods.
componentDIdMount / unmount
constructor
render
didupdate
How do you pass data to a child component?
props