React Flashcards
What is React?
A JavaScript library for building user interfaces for building user interfaces based on UI components.
What is a React element?
an element in the dom
React elements are plain objects, desribes what you want the DOM to look like
A React element is an object representation of a DOM node or component instance building blocks
an object describing a component instance or DOM node and its desired properties
desribes what you want the DOM to look like
How do you mount a React element to the DOM?
with the render method of the reactdom object
ReactDOM.render(element, container[, callback])
How do you mount a React element to the DOM?
ReactDOM.render( )
method
What is Babel?
a JavaScript compiler
compiler takes one language to another
mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments
What is a Plug-in?
a software component(branch of software) that adds a specific feature to an existing computer program
program would work without them
What is a Webpack loader?
are transformations that are applied to the source code of a module webpack does work without loader
They allow you to pre-process files as you import or “load” them A Webpack loader is a node module that applies transformations to the source code to of a module and outputs JavaScript
How can you make Babel and Webpack work together?
Install all dev dependencies
- webpack
- webpack-cli
- babel-loader
- @babel/core
- @babel/plugin-transformation-react-jsx
Configure webpack.config.js file to
- use babel loader as the loader
- use plugin transform react jsx
by adding babel-loader to the list of modules in webpack.config
How can you make Babel and Webpack work together?
Install all dev dependencies
- webpack
- webpack-cli
- babel-loader
- @babel/core
- @babel/plugin-transformation-react-jsx
Configure webpack.config.js file to
- use babel loader as the loader
- use plugin transform react jsx
by adding babel-loader to the list of modules in webpack.config as a loader
What is JSX?
A syntax extension of JavaScript.
which provides a way to structure component rendering using syntax familiar to many developers
generally used for react
supports JS and other stuff
Why must the React object be imported when authoring JSX in a module?
Becasue the React library must be in scope from the JSX code in order to make calls to React.createElement
So Babel understands to compile JSX to JS
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
by installing the react plugin
jsx plugin
- Specify in webpack.config.js to check for jsx to bundle
- Babel loader sends preprocessed files to babel core
- Plugin for convert JSX is read
- Converts to JS
babel loader
What is a React component?
components are like JavaScript functions. a JavaScript class or function that optionally accepts inputs i.e. properties(props) and returns a React element that describes how a section of the UI (User Interface) should appear.
How do you define a function component in React?
write a JavaScript function:
By writing a JavaScript function that accepts props as a single argument and returns a React element
How do you mount a component to the DOM?
render method of ReactDom
ReactDOM.render(element, container)
first argument of the render method