Friday, August 23, 2024

React note

 


1. Install Node.js so that you can run npm command

2. npm install -g create-react-app

   Add the path to env: C:\Users\theuser\AppData\Roaming\npm

3. Run 

create-react-app reactapp

then cd reactapp, npm start to start the react app

4. The virtual DOM is a lightweight copy of DOM, with the key difference that while the real DOM is made up of Node objects,

the virtual DOM is made up of plain JS objects that act as descriptions.

5. Reconciliation compares the virtual tree representing the current state of the user interface with a previous version to 

determine which parts of the user interface need to be updated.

6. Only reactive variables can be modified in the display, once the component is rendered. React uses a concept called "state".

7. [...Array(11).keys()].slice(1)

8. useEffect( function(){ setValue(1);,[] }; ) //conditions = [] means that setValue(1) is executed only on the initial display.



1.
React component names must always start with a capital letter, while HTML tags must be lowercase.
2.
npx will download the package create-react-app, run it once, then delete it from your disk.
npx create-react-app reactapp
npm start
If there's error Cannot read property 'pickAlgorithm' of null, can run the command "npm cache clear --force" to fix it