Skip to content

Commit be157f3

Browse files
authored
Merge pull request #217 from cothvbdnnn/addons-shallow-compare
Translate addons-shallow-compare
2 parents 3110dca + 6b37ffd commit be157f3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

content/docs/addons-shallow-compare.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ 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}
2121

22-
Before [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) was introduced, `shallowCompare` was commonly used to achieve the same functionality as [`PureRenderMixin`](pure-render-mixin.html) while using ES6 classes with React.
22+
Trước đây [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) đã được giới thiệu, `shallowCompare` thường được sử dụng với chức năng tương tự như [`PureRenderMixin`](pure-render-mixin.html) khi sử dụng ES6 class với React.
2323

24-
If your React component's render function is "pure" (in other words, it renders the same result given the same props and state), you can use this helper function for a performance boost in some cases.
24+
Nếu function render của React component của bạn là "pure" (hay nói cách khác, nó render cùng một kết quả với cùng prop và state), bạn có thể sử dụng helper function này để tăng hiệu suất trong một số trường hợp.
2525

26-
Example:
26+
Ví dụ:
2727

2828
```js
2929
export class SampleComponent extends React.Component {
@@ -37,8 +37,8 @@ export class SampleComponent extends React.Component {
3737
}
3838
```
3939

40-
`shallowCompare` performs a shallow equality check on the current `props` and `nextProps` objects as well as the current `state` and `nextState` objects.
41-
It does this by iterating on the keys of the objects being compared and returning true when the values of a key in each object are not strictly equal.
40+
`shallowCompare` thực hiện so sánh nông object để kiểm tra `props` hiện tại và `nextProps` cũng như `state` hiện tại và `nextState`.
41+
Nó thực hiện bằng cách lặp lại các key của các object được so sánh và trả về true khi giá trị của key trong mỗi object không hoàn toàn bằng nhau.
4242

43-
`shallowCompare` returns `true` if the shallow comparison for props or state fails and therefore the component should update.
44-
`shallowCompare` returns `false` if the shallow comparison for props and state both pass and therefore the component does not need to update.
43+
`shallowCompare` trả về `true` nếu so sánh nông cho prop or state không thành công và do đó component sẽ được cập nhật.
44+
`shallowCompare` trả về `false` nếu so sánh nông cho prop and state đều thành công và do đó component không cần cập nhật.

0 commit comments

Comments
 (0)