Flashcards
JS Rappels pour React
Flashcards do conjunto (9)
- 1const grades = [10, 2, 21, 35, 50, -10, 0, 1]; Avoir seulement les notes au dessus de 20 :const result = grades.filter(grade => grade > 20);
- 2Complete the function getPassingTests such that it returns all the test results that have a passing grade (10 and above). const data = [ {id: 1, grade: 20} ]function getPassingTests(results) {
return results.filter(result => result.grade >= 10);
} - 3What is React utilty ?React is a JavaScript library that is only responsible for the view layer of your application.
- 4Types of import + Syntax- Default import : import Something from "package-name".
- Named export : import {Something} from "package-name". - 5ReactDOM & Virtual DOM DefReactDOM
- Glue between React and the DOM
- Library that efficiently updates the DOM based on that Virtual DOM.
VirtualDOM
- Representation of the UI kept in memory & synced with the DOM.
- Exists to figure out which parts of the UI need to be updated and then batch these changes together. - 6ReconciliationProcess of syncing the Virtual DOM to the actual DOM.
- 7With ReactDOM, how to render React elements on the page ? + precautionimport {createRoot} from "react-dom/client";
const root = document.querySelector("\#root");
createRoot(root).render(React.createElement("p", {}, "Hello World"));
We create the root of the React app using createRoot(root).
On the result of createRoot(root), we call .render() and pass to it our React element.
(#root is an existing html element)
precaution : This root element that you pass to ReactDOM will become completely managed by React. So you should not write any kind of JavaScript that changes its content - 8Difference between React & document createElement :document.createElement returns a DOM element (for example a div or an h1). Whereas React.createElement returns an object that represents the DOM element (=> because React operates a Virtual DOM).
- 9What is an element in React ?- The smallest building block
- (Represents what the smallest piece of your User Interface will look like)
Informações
- Descrição
- vaze JS React FlashCards sobre JS Rappels pour React, criado por dadou siplancin em 03-03-2023.
- Criado por
- dadou siplancin
- Visualizações
- 0
- Avaliação