1. what's the react ?
React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.
Build encapsulated components that manage their own state, then compose them to make complex UIs.
2. why react ?
better performance compared to those that use other frameworks. Because ReactJS helps to prevent updating of DOM, ReactJS was designed to help improve the total rendered pages from the website server.
Working with the DOM API is hard. React basically gives developers the ability to work with a virtual browser that is more friendly than the real browser. React’s virtual browser acts like an agent between the developer and the real browser.
3. principle of react ?
- what I know
- Virtual DOM model
- Life cycle management
- setState machanism
- diff algorithm
- one-way data flow
Virtual DOM model
Virtual DOM is actually an abstraction of real DOM, a JS object. React all surface operations are actually virtual DOM operations.
Life cycle management
We know that react’s state management usesimmutableConceptual design, so when you want to change the state value, you can’t use the traditional assignment methodthis.state.counter = 1To modify, you need to callsetState(updater[, callback])Method of modification.
DiffThe algorithm is used to calculate the difference between two virtual DOMS, which is the most expensive part of react.