React JS Flashcards
What is React?
A JavaScript library for building user interfaces
What is a React element?
A JavaScript object created using React that models a DOM element
How do you mount a React element to the DOM?
ReactDOM.render(newReactElement, existingDOMElement);
What is JSX?
It is a syntax extension of JavaScript that is used to describe HTML elements, and can be converted into React elements using Babel
Why must the React object be imported when authoring JSX in a module?
JSX code is syntactic sugar for a React element
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
You assign the module.exports.module.rules[0].use.loader = ‘babel-loader’ in the webpack.config.js file
What is a React component?
A JavaScript function/class that takes in a props argument to construct a React element
How do you define a function component in React?
function SomeComponent([props]) { return ... }
How do you mount a component to the DOM?
ReactDOM.render(Some Component />, existingDOMElement);
Why do you need to capitalize React components?
React treats components starting with a lowercase letter as a DOM tag (converts it to string)
What are props in React?
They are objects holding the “properties” to be used in making a React element
How do you pass props to a component?
You specify them as you would write attributes in an HTML element opening tag
How do you write JavaScript expressions in JSX?
between curly braces {expression}
How do you create “class” component in React?
class SomeComponent extends React.Component { render() { return ... } }
How do you access props in a class component?
this.props