X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=react.md;h=bca3061597b258f02b901b920ec3b566b6def1e9;hb=a10720fa0020b12af6d6193a9a5a5b28dd96b217;hp=0f722cbc7dbf78089e8459319955f78f82e3aaf9;hpb=e460b5b8867dc446e51485643faeaee827d89ff8;p=twpd%2Fmaster.git diff --git a/react.md b/react.md index 0f722cb..bca3061 100644 --- a/react.md +++ b/react.md @@ -4,7 +4,7 @@ category: React layout: 2017/sheet ads: true tags: [Featured] -updated: 2020-07-04 +updated: 2020-07-05 weight: -10 keywords: - React.Component @@ -215,8 +215,7 @@ And without constructor using [Babel](https://babeljs.io/) with [proposal-class- ```jsx class Hello extends Component { - state = { visible: true } - } + state = { visible: true } } ``` {: data-line="2"} @@ -282,6 +281,7 @@ Lifecycle {: .-two-column} ### Mounting + | Method | Description | | ------------------------ | ---------------------------------------------------------------------------------------------------- | | `constructor` _(props)_ | Before rendering [#](https://reactjs.org/docs/react-component.html#constructor) | @@ -297,6 +297,7 @@ Set initial the state on `constructor()`. Add DOM event handlers, timers (etc) on `componentDidMount()`, then remove them on `componentWillUnmount()`. ### Updating + | Method | Description | | ------------------------------------------------------- | ---------------------------------------------------- | | `componentDidUpdate` _(prevProps, prevState, snapshot)_ | Use `setState()` here, but remember to compare props |