Skip to content

Commit 8f2274a

Browse files
authored
Merge branch 'main' into translate
2 parents 9b99ab2 + be157f3 commit 8f2274a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

content/docs/addons-shallow-compare.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ layout: docs
66
category: Reference
77
---
88

9-
> Note:
9+
> Lưu ý:
1010
>
11-
> `shallowCompare` is a legacy add-on. Use [`React.memo`](/docs/react-api.html#reactmemo) or [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
11+
> `shallowCompare` được kế thừa từ add-on. Sử dụng [`React.memo`](/docs/react-api.html#reactmemo) hoặc [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) thay thế.
1212
1313
**Importing**
1414

1515
```javascript
1616
import shallowCompare from 'react-addons-shallow-compare'; // ES6
17-
var shallowCompare = require('react-addons-shallow-compare'); // ES5 with npm
17+
var shallowCompare = require('react-addons-shallow-compare'); // ES5 với npm
1818
```
1919

20-
## Overview {#overview}
20+
## Tổng quát {#overview}
21+
2122

2223
Trước khi [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) được giới thiệu, `shallowCompare` thường được sử dụng có chức năng tương tự như [`PureRenderMixin`](pure-render-mixin.html) trong khi sử dụng các lớp ES6 với React.
2324

2425
Nếu render function của React component là "thuần" (nói một cách khác, nó trả về cùng một kết quả với cùng props và state), bạn có thể dùng helper function để tăng cường hiệu suất trong một số trường hợp.
2526

27+
2628
Ví dụ:
2729

2830
```js
@@ -42,3 +44,4 @@ export class SampleComponent extends React.Component {
4244
`shallowCompare` trả về `true` nếu phép so sánh shallow cho props hoặc state thất bại và component sẽ được cập nhật.
4345

4446
`shallowCompare` trả về `false` nếu phép so sánh shallow cho props hoặc state thành công và component không cần cập nhật.
47+

0 commit comments

Comments
 (0)