React Structure Flashcards
Why are these separated mean
1. import React from ‘react’
2. import ReactDOM from ‘react-dom/client’
The first line is for the react package and the second is for the view. Separation cause is that react can work with every view so replacing 2 with your view.
What do you need at the end of the file for your component to get displayed?
export App
Why was React invented by Facebook?
To decrease the amount of DOM manipulation which increaser development time, performance and bugs.
How does React improve the DOM problem?
By having its own virtual DOM (inside the render method of the component) that compare it with the DOM to see what changed and then changes the DOM.
What is JSX ?
It is an HTML-like language used in React to work with the virtual DOM.
How can I write JS expression in JSX?
Rap them in {}
What is the need for key in React arryas?
Less manipulation to the DOM. It tells react which card is which so in the case of removing or editing that card it will find it in the DOM and do what necessary.
What are pure components | deterministic |dumb components?
They return the same thing as long as they are given the same input
What are props?
Props are the information that you pass to a JSX tag.
What is state?
It is an object that describes your application. They hold the things that can change.
What is mounting?
Adding component to the screen.
When will the mounting methods get called?
- Component creation
- DOM insertion
What is updating?
It is caused by changes to props or state.
what is unmounting?
Removing component form the screen.
What is the render method job?
The render method should specify what you want to appear on the screen.
It is recommended to keep the render method pure, where should the side effects take place?
- Event handlers
- componentDidMount.
What is the order of each component life cycle?
Check the diagram :
https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/
What are component children?
They are JSX placed inside a JSX parent component, where they are represented as props in the parent.
What is a script ?
List of comands excecuted by a prohram.