React Fundamentals Flashcards
Features of React
JSX
components
virtual DOM
DOM
one way data-binding
high performance
JSX
syntax extension of Javascript used in React. Allows us to write HTML and JS in the same file. Web browsers cannot read JSX directly. They can only read regular JS objects. For a web browser to read a JSX file, the file must be transpiled into a regular JavaScript object via a transpiler like Babel
components
splits user interface into independent reusable parts that can be processed separately
virtual DOM
lightweight representation of the real DOM. When state changes, the virtual DOM changes only that object in the real DOM instead of re-rendering the entire DOM
DOM
Document object model, an HTML document with a tree structure. Each branch leads to a node. Each node contains objects (Objects can be in JS not JSX)
one way data-binding
Unidirectional flow . When data flows in one direction, it’s easier to debug errors and ID the root cause quickly
high performance
react apps only re-render components that have state change instead of all components within a tree.
useState
useEffect
useCallback
useMemo
Rules of hooks
Don’t call hooks inside loops, conditions or nested functions
Only call hooks from react functional components or custom hooks
React hooks are internally implemented as a _____
queue
React hooks are internally implemented as a queue, which each hook represented as a book having the reference to the next one (linked list, anyone?). This is way react hooks relies on the order in which hooks are called, and why they must be called on the top level of our components.
True or false;
On each render, React keeps a copy of the dependency array and compares it with the previous dependency array. Objects are compared by reference, not value
True
On each render, React keeps a copy of the dependency array and compares it with the previous dependency array. Objects are compared by reference, not value
True or false
Sometimes it’s better to create a function in useEffect if it’s only being used inside of useEFfect. It prevents the function from being created each time the component that uses the context hook usecontext is created
True
Sometimes it’s better to create a function in useEffect if it’s only being used inside of useEFfect. It prevents the function from being created each time the component that uses the context hook usecontext is created