Browse Source

docs: fix typos in Component section of Legacy APIs (#5842)

main
Ruchita 2 years ago
committed by GitHub
parent
commit
53f6bb709b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/content/reference/react/Component.md

6
src/content/reference/react/Component.md

@ -412,7 +412,7 @@ Run the [`rename-unsafe-lifecycles` codemod](https://github.com/reactjs/react-co
If you define the `componentWillUnmount` method, React will call it before your component is removed *(unmounted)* from the screen. This is a common place to cancel data fetching or remove subscriptions. If you define the `componentWillUnmount` method, React will call it before your component is removed *(unmounted)* from the screen. This is a common place to cancel data fetching or remove subscriptions.
The logic inside `componentWillUnmount` should "mirror" the logic inside [`componentDidMount`.](#componentdidmount) For example, if `componentDidMount` sets up a subscription, `componentWillUnmount` should clean up that subscription. If the cleanup logic your `componentWillUnmount` reads some props or state, you will usually also need to implement [`componentDidUpdate`](#componentdidupdate) to clean up resources (such as subscriptions) corresponding to the old props and state. The logic inside `componentWillUnmount` should "mirror" the logic inside [`componentDidMount`.](#componentdidmount) For example, if `componentDidMount` sets up a subscription, `componentWillUnmount` should clean up that subscription. If the cleanup logic in your `componentWillUnmount` reads some props or state, you will usually also need to implement [`componentDidUpdate`](#componentdidupdate) to clean up resources (such as subscriptions) corresponding to the old props and state.
```js {20-22} ```js {20-22}
class ChatRoom extends Component { class ChatRoom extends Component {
@ -739,8 +739,8 @@ React calls `shouldComponentUpdate` before rendering when new props or state are
#### Parameters {/*shouldcomponentupdate-parameters*/} #### Parameters {/*shouldcomponentupdate-parameters*/}
- `nextProps`: The next props that the component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed. - `nextProps`: The next props that the component is about to render with. Compare `nextProps` to [`this.props`](#props) to determine what changed.
- `nextState`: The next props that the component is about to render with. Compare `nextState` to [`this.state`](#props) to determine what changed. - `nextState`: The next state that the component is about to render with. Compare `nextState` to [`this.state`](#props) to determine what changed.
- `nextContext`: The next props that the component is about to render with. Compare `nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype) (modern) or [`static contextTypes`](#static-contexttypes) (legacy). - `nextContext`: The next context that the component is about to render with. Compare `nextContext` to [`this.context`](#context) to determine what changed. Only available if you specify [`static contextType`](#static-contexttype) (modern) or [`static contextTypes`](#static-contexttypes) (legacy).
#### Returns {/*shouldcomponentupdate-returns*/} #### Returns {/*shouldcomponentupdate-returns*/}

Loading…
Cancel
Save