React Flashcards
What is Array.prototype.filter useful for?
It “filters” out the elements you don’t want and returns a new array of the elements you do want
It passes a function as the second argument to filter it out
What is Array.prototype.map useful for?
It applies some kind of function to every element in the array and returns a NEW array with those values
What is Array.prototype.reduce useful for?
It’s helpful for getting 1 result from all the elements of 1 array
The result, however, will move from ([0], [1]) the result of which is then used for the next function with the next one in line, [2], and then that result for the next one [3], and so on and so forth
What is Webpack?
Starts from multiple modules and packages and the end results is fewer files, common case is to make 1 bundle/file
Let’s us write modules but also support any module format and handle resources and assets at the same time
It’s a tool that lets you bundle your JS applications (supporting ESM and CommonJS) and it can be extended to support many different assets like images, fonts and stylesheets
How do you add a devDependency to a package?
Npm install [name like webpack or webpack-cli, or both] –save-dev
What is an NPM script?
Command line command with a nickname
The “scripts” property in the package.json file supports a number of built-in scripts and their preset life cycle events
How do you execute Webpack with npm run?
Add the nickname to the script property with whatever command we want then we command like so
Npm run [name like build]
What is React?
A JavaScript library for building user interfaces
It’s a package from npm
What is a React element?
It’s an object
React.createElement( ‘dom element in string’, [props, if nothing null], [children] )
How do you mount a React element to the DOM?
Create the html element where you want the object placed
Then const root = create a ReactDom.createRoot()
Then render method on that root var
What is Babel?
It’s a toolchain mainly used to convert ECMAScript 2015+ code into backwards compatible version of JavaScript in current and older browsers or environments, or back-covert JSX
What is a Plug-in?
This is a software component that adds a specific feature to an existing computer program. When a program supports plug-ins, it enables customization
What is a Webpack loader?
They are transformations that are applied to the source code of a module. They allow you to pre-process files as you “import” or “load” them.
Thus, they’re kind of like “tasks” and provide a powerful way to handle front-end build steps
Can transform files from different language like TypeScript to JavaScript or load inline images as data URLs.
How can you make Babel and Webpack work together?
You have to install babel-loader as a devDependency
Npm install babel-loader
What is JSX?
It’s a syntax extension to JavaScript
JavaScript plus more stuff (additional syntax), no HTML
Recommended to use with React to describe what the UI should look like, looking like template language but with the power of JavaScript