Basics Flashcards
What is React?
React is a JS library for creating User Interface components.
What does React do?
When data in the User Interface changes, React updates the User Interface to match that data.
How does React work?
On the initial request, the component is rendered and the HTML markup is generated and added to the document. When the data is changed, Reacts will only re-render the bit of data that has been changed in the component. It does so by using a diff on what has been changed on the component and what was originally there. That minimum change can be applied to the DOM.
What is reconciliation?
The process of using a diff algorithm to check the difference between the DOM trees of the initial state and the changed state so that React can render a portion of a component in the most efficient way possible.
Where does React come from?
Facebook and Instagram
What is JSX?
JSX is a JS syntax extension that resembles HTML and XML.
What is XML?
XML stands for Extensible Markup Language. It is a markup language that defines a set of rules for encoding documents in a format that is both human and machine readable.
How can you use JS inside of JSX syntax?
Insert JS inside of {curly brackets} and insert this in between element tags or for markup attribute values
Why would the below code cause an error? What kind of error does it give? const myElement = (
{
1 + 2 + 3;
4 + 5 + 6;
}
);
It will give a syntax error, because the JSX expects JS expressions to be a single line expression.
Why do we use Babel?
JSX cannot be interpreted by browsers, so JSX code must be passed through a preprocess that transpiles it into vanillas JS.
What are components?
Components are the building blocks of a React view layer. They are JS functions that return HTML to be rendered onto a document.
What is root and why does it matter to React?
I’m getting replaced :(
“root” is the element which will serve as the hook into which we insert our React component.
What are the two ways to declare components?
Functional Component and Class Component
How is a class component written? Write a class component for ‘TodoList’.
class TodoList extends React.Component {
}
When do you write a functional component as opposed to a class component?
when we need to use hooks