LFZ Quiz questions (Senior parts 2) Flashcards
(react-elements)
What is React?
A JavaScript library for building user interfaces.
(react-elements)
What is a React element?
Object
(react-elements)
How do you mount a React element to the DOM?
ReactDOM.render(element, container[, callback])
Render a React element into the DOM in the supplied container and return a reference to the component (or returns null for stateless components).
(babel-intro)
What is Babel?
Babel is a JavaScript compiler.
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
(babel-intro)
What is a Plug-in?
In computing, a plug-in (or plugin, add-in, add-in, add-on, or addon) is a software component that adds a specific feature to an existing computer program. When a program supports plug-ins, it enables customization.
(babel-intro)
What is a Webpack loader?
Loaders 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, loaders are kind of like “tasks” in other build tools and provide a powerful way to handle front-end build steps. Loaders can transform files from a different language (like TypeScript) to JavaScript or load inline images as data URLs. Loaders even allow you to do things like import CSS files directly from your JavaScript modules!
(babel-intro)
How can you make Babel and Webpack work together?
within a webpack.config.js file, we can add a rule to use loader for the babel-loader and plugins(ex. babel-loader).
Or we can use inline command or CLI.
(react-jsx)
What is JSX?
It is a syntax extension to JavaScript used in React. It describes what the UI should look like. JSX produces React “elements”
(react-jsx)
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
We can use a babel-loader and a plugin of ‘@babel/plugin-transform-react-jsx’.
(react-function-components)
What is a React component?
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
(react-function-components)
How do you define a function component in React?
function keyword, component name and function parameter of property.
(react-function-components)
How do you define a function component in React?
It is very similar to the function declaration of JavaScript. function keyword, component name and function parameter as property. Function name should start with a capital letter.
(react-function-components)
How do you mount a component to the DOM?
we can use ReactDOM.render() method with passing in the first parameter as React element.
(react-props-and-expressions)
What are props in React?
Props in React is arbitrary inputs when components are declared and object.
(react-props-and-expressions)
How do you pass props to a component?
- You can pass any JavaScript expression as a prop, by surrounding it with {}.
- You can pass a string literal as a prop.
- If you pass no value for a prop, it defaults to true.
- If you already have props as an object, and you want to pass it in JSX, you can use … as a “spread” operator to pass the whole props object.