Skip to content

Conversation

sebmarkbage
Copy link
Contributor

facebook/react#13748

Pretty straight forward.

Still undecided whether we should support forwardRef by default or not. facebook/react#13822

@reactjs-bot
Copy link

Deploy preview for reactjs ready!

Built with commit 6bb9e96

https://deploy-preview-1266--reactjs.netlify.com

const MyComponent = React.pure(render, equals);
```

This method only exists as a **[performance optimization](/docs/optimizing-performance.html).** Do not rely on it to "prevent" a rendering, as this can lead to bugs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This method only exists as a **[performance optimization](/docs/optimizing-performance.html).** Do not rely on it to "prevent" a rendering, as this can lead to bugs.
This method only exists as a **[performance optimization](/docs/optimizing-performance.html).** Do not rely on it to "prevent" a render, as this can lead to bugs.


React components can also be defined as functions which can be wrapped by further functionality.

- [`React.pure`](#reactpure)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`React.pure`](#reactpure)
- [`React.memo`](#reactmemo)

### `React.pure`

```javascript
const MyComponent = React.pure(function(props) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const MyComponent = React.pure(function(props) {
const MyComponent = React.memo(function(props) {

});
```

`React.pure` is a [higher order component](/docs/higher-order-components.html). It's similar to [`React.PureComponent`](#reactpurecomponent) but for function components instead of classes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`React.pure` is a [higher order component](/docs/higher-order-components.html). It's similar to [`React.PureComponent`](#reactpurecomponent) but for function components instead of classes.
`React.memo` is a [higher order component](/docs/higher-order-components.html). It's similar to [`React.PureComponent`](#reactpurecomponent) but for function components instead of classes.


`React.pure` is a [higher order component](/docs/higher-order-components.html). It's similar to [`React.PureComponent`](#reactpurecomponent) but for function components instead of classes.

If your function component renders the same result given the same props, you can wrap it in a call to `React.pure` for a performance boost in some cases by memoizing the result.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If your function component renders the same result given the same props, you can wrap it in a call to `React.pure` for a performance boost in some cases by memoizing the result.
If your function component renders the same result given the same props, you can wrap it in a call to `React.memo` for a performance boost in some cases by memoizing the result.

otherwise return false
*/
}
const MyComponent = React.pure(render, equals);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const MyComponent = React.pure(render, equals);
const MyComponent = React.memo(render, equals);

* * *

### `React.pure`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### `React.pure`
### `React.memo`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants