Here is a summary of the core features. We will cover each feature in detail throughout the examples.
These methods can be overridden for each component, to run code during a specific lifecycle phase.
constructor()
componentWillMount()
render()
componentDidMount()
componentWillReceiveProps()
shouldComponentUpdate()
componentWillUpdate()
render()
componentDidUpdate()
componentWillUnmount()
componentDidCatch()
We will explain these core features in more detail with a couple of code snippets in the next section.
The JavaScript syntax that you will see in our examples is ECMAScript 6 (ES6) notation. If you need to run your web app inside older web browsers, you can use Babel (https://babeljs.io/) to transpile ES6 code to ES5. Here is an example how babel will transpile the ES6 arrow function to a regular ES5 function.
ES6 syntax | Transpiled to ES5 syntax |
[1,2,3,4].map(n => n + 1); |
[1,2,3,4].map( function(n) { return n + 1; } ); |
https://blog.codecentric.de/en/2017/11/developing-modern-offline-apps-reactjs-redux-electron-part-2-reactjs-basics/
原文:https://www.cnblogs.com/feng9exe/p/11084574.html