What is React?
What is a React element?
React elements are objects that describe what will be shown. React DOM takes care of manipulating the DOM with the provided React elements. They are not DOM objects
How do you mount a React element to the DOM?
const root = ReactDOM.createRoot($container)root.render(myElement)What’s the difference between a library and a framework?
app.get and app.post, but something else handles when they get calledWhat is Babel?
Babel is a toolchain that can analyze JavaScript code that is written with newer standards and convert it into backwards-compatible JavaScript.
A JavaScript compiler
What is a Plug-in?
A plugin enhances a program’s capabilities
What is a Webpack loader?
A Webpack loader is a step/operation that acts on source code, allowing the code to be transformed/processed as Webpack bundles the code together
How can you make Babel and Webpack work together?
The babel-loader should be specified in the webpack.config.js file under module.rules
Additionally, babel-loader should be npm installed along with any Babel plugins such as @babel/plugin-transform-arrow-functions (don’t forget @babel/core as well)
Plugins to be used should be specified in the module.rules as well
What is JSX?
Why must the React object be imported when authoring JSX in a module?
The React object has the methods necessary to actually create the React elements (the objects). Those methods are called after the JSX syntax is converted into normal JavaScript.
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
babel-loader, @babel/core, and the plugin @babel/plugin-transform-react-jsx using NPM (don’t forget webpack and babel in general)webpack.config.js filenpm run build, it will process .jsx files using the pluginWhat is a React component?
It’s a function that outputs a React element
How do you define a function component in React?
function CapitalName(props) { return Stuff {props.something} Here }propsreturns a React elementprops objectHow do you mount a component to the DOM?
ReactDOM.createRoot($DOMroot) to create the React DOM root.render() with the desired React elements created from the React component insideWhat are props in React?
Props are arbitrary inputs passed to a React component (props is an object)
How do you pass props to a component?
or if you have an expression as a prop, wrap the expression in curly braces likeHow do you write JavaScript expressions in JSX?
Wrap them in curly braces, otherwise they’re the same as JavaScript expressions
How do you create “class” component in React?
React.Component prototypeextend syntax like class MyClass extends React.Component {}render method defined (which must return a React element)How do you access props in a class component?
The props object will be a property of this, so use this.props to access any props
What is the purpose of state in React?
State allows a React element to not only handle events but also keep the functionality of handling events within the component
How to you pass an event handler to a React element?
Within the return of the React element (the render()), add the event as a prop to the React element and specify the handler function as the value to that prop but remember to enclose it within curly braces and specify that it is a method of this
What are controlled components?
Controlled components are React components that render the form control and handle the state of the form control with the React state as the single source of truth
What two props must you pass to an input for it to be “controlled”?
value with the associated key value in this.state for that inputonChange, and this event handler should be using setState() in order to manage the state of the componentWhatArraymethod is commonly used to create a list of React elements?
myArray.map() because it returns an array of the same length as myArray, one for each element