diff --git a/bash.md b/bash.md index b06e44e3ddc..8509267478b 100644 --- a/bash.md +++ b/bash.md @@ -102,9 +102,11 @@ See: [Unofficial bash strict mode](http://redsymbol.net/articles/unofficial-bash echo {A,B}.js ``` -| `{A,B}` | Same as `A B` | +| Expression | Description | +| ---------- | ------------------- | +| `{A,B}` | Same as `A B` | | `{A,B}.js` | Same as `A.js B.js` | -| `{1..5}` | Same as `1 2 3 4 5` | +| `{1..5}` | Same as `1 2 3 4 5` | See: [Brace expansion](http://wiki.bash-hackers.org/syntax/expansion/brace) @@ -163,19 +165,19 @@ DIR=${SRC%$BASE} #=> "/path/to/" (dirpath) ### Substitution -| Code | Description | -| --- | --- | -| `${FOO%suffix}` | Remove suffix | -| `${FOO#prefix}` | Remove prefix | -| --- | --- | -| `${FOO%%suffix}` | Remove long suffix | -| `${FOO##prefix}` | Remove long prefix | -| --- | --- | -| `${FOO/from/to}` | Replace first match | -| `${FOO//from/to}` | Replace all | -| --- | --- | -| `${FOO/%from/to}` | Replace suffix | -| `${FOO/#from/to}` | Replace prefix | +| Code | Description | +| ----------------- | ------------------- | +| `${FOO%suffix}` | Remove suffix | +| `${FOO#prefix}` | Remove prefix | +| --- | --- | +| `${FOO%%suffix}` | Remove long suffix | +| `${FOO##prefix}` | Remove long prefix | +| --- | --- | +| `${FOO/from/to}` | Replace first match | +| `${FOO//from/to}` | Replace all | +| --- | --- | +| `${FOO/%from/to}` | Replace suffix | +| `${FOO/#from/to}` | Replace prefix | ### Comments @@ -563,15 +565,19 @@ History ### Commands -| `history` | Show history | +| Command | Description | +| --------------------- | ----------------------------------------- | +| `history` | Show history | | `shopt -s histverify` | Don't execute expanded result immediately | ### Expansions -| `!$` | Expand last parameter of most recent command | -| `!*` | Expand all parameters of most recent command | -| `!-n` | Expand `n`th most recent command | -| `!n` | Expand `n`th command in history | +| Expression | Description | +| ------------ | ---------------------------------------------------- | +| `!$` | Expand last parameter of most recent command | +| `!*` | Expand all parameters of most recent command | +| `!-n` | Expand `n`th most recent command | +| `!n` | Expand `n`th command in history | | `!` | Expand most recent invocation of command `` | ### Operations @@ -737,10 +743,12 @@ read -n 1 ans # Just one character ### Special variables -| `$?` | Exit status of last task | -| `$!` | PID of last background task | -| `$$` | PID of shell | -| `$0` | Filename of the shell script | +| Expression | Description | +| ---------- | ---------------------------- | +| `$?` | Exit status of last task | +| `$!` | PID of last background task | +| `$$` | PID of shell | +| `$0` | Filename of the shell script | See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables). diff --git a/react.md b/react.md index 2a4eb52f41d..19c48c92494 100644 --- a/react.md +++ b/react.md @@ -282,29 +282,27 @@ Lifecycle {: .-two-column} ### Mounting - -| Method | Description | -| --- | --- | -| `constructor` _(props)_ | Before rendering [#](https://reactjs.org/docs/react-component.html#constructor) | -| `componentWillMount()` | _Don't use this_ [#](https://reactjs.org/docs/react-component.html#componentwillmount) | -| `render()` | Render [#](https://reactjs.org/docs/react-component.html#render) | -| `componentDidMount()` | After rendering (DOM available) [#](https://reactjs.org/docs/react-component.html#componentdidmount) | -| --- | --- | -| `componentWillUnmount()` | Before DOM removal [#](https://reactjs.org/docs/react-component.html#componentwillunmount) | -| --- | --- | -| `componentDidCatch()` | Catch errors (16+) [#](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html) | +| Method | Description | +| ------------------------ | ---------------------------------------------------------------------------------------------------- | +| `constructor` _(props)_ | Before rendering [#](https://reactjs.org/docs/react-component.html#constructor) | +| `componentWillMount()` | _Don't use this_ [#](https://reactjs.org/docs/react-component.html#componentwillmount) | +| `render()` | Render [#](https://reactjs.org/docs/react-component.html#render) | +| `componentDidMount()` | After rendering (DOM available) [#](https://reactjs.org/docs/react-component.html#componentdidmount) | +| --- | --- | +| `componentWillUnmount()` | Before DOM removal [#](https://reactjs.org/docs/react-component.html#componentwillunmount) | +| --- | --- | +| `componentDidCatch()` | Catch errors (16+) [#](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html) | 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 | -| `shouldComponentUpdate` *(newProps, newState)* | Skips `render()` if returns false | -| `render()` | Render | -| `componentDidUpdate` *(prevProps, prevState)* | Operate on the DOM here | +| Method | Description | +| ------------------------------------------------------- | ---------------------------------------------------- | +| `componentDidUpdate` _(prevProps, prevState, snapshot)_ | Use `setState()` here, but remember to compare props | +| `shouldComponentUpdate` _(newProps, newState)_ | Skips `render()` if returns false | +| `render()` | Render | +| `componentDidUpdate` _(prevProps, prevState)_ | Operate on the DOM here | Called when parents change properties and `.setState()`. These are not called for initial renders. @@ -714,40 +712,54 @@ import PropTypes from 'prop-types' See: [Typechecking with PropTypes](https://reactjs.org/docs/typechecking-with-proptypes.html) -| `any` | Anything | +| Key | Description | +| ----- | ----------- | +| `any` | Anything | #### Basic -| `string` | | -| `number` | | -| `func` | Function | -| `bool` | True or false | +| Key | Description | +| -------- | ------------- | +| `string` | | +| `number` | | +| `func` | Function | +| `bool` | True or false | #### Enum -| `oneOf`_(any)_ | Enum types | -| `oneOfType`_(type array)_ | Union | +| Key | Description | +| ------------------------- | ----------- | +| `oneOf`_(any)_ | Enum types | +| `oneOfType`_(type array)_ | Union | #### Array -| `array` | | -| `arrayOf`_(...)_ | | +| Key | Description | +| ---------------- | ----------- | +| `array` | | +| `arrayOf`_(...)_ | | #### Object -| `object` | | -| `objectOf`_(...)_ | Object with values of a certain type | -| `instanceOf`_(...)_ | Instance of a class | -| `shape`_(...)_ | | +| Key | Description | +| ------------------- | ------------------------------------ | +| `object` | | +| `objectOf`_(...)_ | Object with values of a certain type | +| `instanceOf`_(...)_ | Instance of a class | +| `shape`_(...)_ | | #### Elements -| `element` | React element | -| `node` | DOM node | +| Key | Description | +| --------- | ------------- | +| `element` | React element | +| `node` | DOM node | #### Required -| `(···).isRequired` | Required | +| Key | Description | +| ------------------ | ----------- | +| `(···).isRequired` | Required | ### Basic types