React Flashcards
What is React?
a JavaScript library for creating user interfaces
What is a React element?
a plain object
How do you mount a React element to the DOM?
ReactDOM.render(element, container)
What is JSX?
a syntax extension to JS
Why must the React object be imported when authoring JSX in a module?
JSX compiles into to React.createElement, React library must be in scope
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Webpack bundles files, sends files through Babel loader to transform them into valid JS, and sends transformed files back to Webpack
What is a React component?
like JS functions, accepts inputs(props) and returns React elements
How do you define a function component in React?
function definition with props param and returns React element
How do you mount a component to the DOM?
call the component in a React element with props
What are props in React?
object argument for function components
How do you pass props to a component?
React element
How do you write JavaScript expressions in JSX?
{expression}
How do you create “class” component in React?
class ClassName extends React.Component { render( ) { return React element; } }
How do you access props in a class component?
{ this.props }
What is the purpose of state in React?
represents information about the component’s current situation