React Flashcards
What is React?
JS library for building user interface
What is a React element?
What gets returned from components. An object that virtually describes the DOM nodes.
How do you mount a React element to the DOM?
render( ) method
What is JSX?
Syntax extension to JavaScript to describe what UI should look like.
Why must the React object be imported when authoring JSX in a module?
Because JSX works with react. It produces react elements.
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
@babel/plugin-transformed-react-jsx
What is a React component?
JS function or class that returns react elements
How do you define a function component in React?
Similar to JS
Define the function (parameters)
return JSX/React Elements
First letters of function name must be capitalized!
How do you mount a component to the DOM?
render( ) method
What are props in React?
An object in react
How do you pass props to a component?
Property key = value (similar to attribute/value in HTML)
How do you write JavaScript expressions in JSX?
{ }
How do you create “class” component in React?
Class keyword extends keyword React.Component
- with required render method
How do you access props in a class component?
this.props
What is the purpose of state in React?
Changes your elements