React Flashcards
What are the features of React?
JSX: syntax extension for JS, can write HTML in same file as JS
Components: splits application into independent reusable parts
Virtual DOM: when state changes virtual DOM only changes the object in the real DOM instead of updating all the objects
Can web browsers read JSX directly?
No, they are built to only read regular JS objects which JSX is not.
What is the virtual DOM?
A lightweight representation of the real DOM stored in memory, when the state of an object changes, the virtual DOM changes only that object in the real DOM
What is the difference between the ES6 and ES5 standards?
components and functions
exports vs export
require vs import
What is an event in React?
An action the user or system triggers such as a mouse click, pressing a button
ex. onClick is the event
What is a synthetic event?
An example is preventDefault()
Explain how lists work in React.
the traversal of lists is done using the map() function
Why is there a need for using keys in Lists?
a key is a unique identifier and is used to see which items have changed from the list and determines which items need to be re-rendered.
What are forms in React?
Forms allow the user to interact with the application and enter the required information whenever needed.
How do you create forms in React?
set useState for each input, use onChange to set the state of specific field, create a handleSubmit to for when the user clicks a submit button.
How do you write comments in React?
For single line #
For multiple lines {/* */}
What is an arrow function and how is it used in React?
shorter way of writing a function and there is no need to bind this inside the constructor.
What are components in React?
A piece of the user interface. Components splits the interface into independent reusable parts that can be processed separately.
Function components vs Class components
Functional: AKA stateless components, have no state of their own and only contain render methods
Class: AKA stateful components, can hold and manage their own state and have a separate render method to return JSX.
What is the use of the render() method in React?
Returns the HTML which is displayed in the component