Skip to content

Commit f351b45

Browse files
authored
Update higher-order-components.md
1 parent aeb5e27 commit f351b45

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

content/docs/higher-order-components.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,15 @@ const enhance = compose(
289289
const EnhancedComponent = enhance(WrappedComponent)
290290
```
291291

292-
(This same property also allows `connect` and other enhancer-style HOCs to be used as decorators, an experimental JavaScript proposal.)
292+
(Property này cũng cho phép `connect` với enhancer-style HOCs để sử dụng như decorators, một JavaScript proposal.)
293293

294-
The `compose` utility function is provided by many third-party libraries including lodash (as [`lodash.flowRight`](https://lodash.com/docs/#flowRight)), [Redux](https://redux.js.org/api/compose), and [Ramda](https://ramdajs.com/docs/#compose).
295-
Hàm `compose` thì được cung cấp bở nhiều thư viện third-party bao gồm lodash ([`lodash.flowRight`](https://lodash.com/docs/#flowRight)) và [Ramda](https://ramdajs.com/docs/#compose).
294+
Hàm `compose` được cung cấp bởi nhiều third-party libraries như lodash ([`lodash.flowRight`](https://lodash.com/docs/#flowRight)), [Redux](https://redux.js.org/api/compose), và [Ramda](https://ramdajs.com/docs/#compose).
296295

297296
## Quy ước: Cách đặt tên HOC để tiện cho việc debug (tìm và gỡ lỗi){#convention-wrap-the-display-name-for-easy-debugging}
298297

299298
Những container component tạo bởi HOCs đều xuất hiện trong [React Developer Tools](https://github.com/facebook/react/tree/main/packages/react-devtools) như bao component khác. Để dễ debug, chọn tên sao cho nó thể hiện rằng nó được sinh ra từ HOC.
300299

301-
The most common technique is to wrap the display name of the wrapped component. So if your higher-order component is named `withSubscription`, and the wrapped component's display name is `CommentList`, use the display name `WithSubscription(CommentList)`:
300+
Một cách thông dụng nhất là bọc display name của component được bọc. Vì vậy nếu higher-order component của bạn có tên `withSubscription`, và tên của wrapped component hiển thị là `CommentList`, thì bạn nên sử dụng tên hiển thị là `WithSubscription(CommentList)`:
302301
Một kỹ thuật thường gặp là tạo tên với tên của component bên trong. Nếu HOC có tên là `withSubscription`, và component con có tên là `CommentList`, hãy dùng tên `WithSubscription(CommentList)`
303302

304303
```js
@@ -316,7 +315,7 @@ function getDisplayName(WrappedComponent) {
316315

317316
## Caveats {#caveats}
318317

319-
Higher-order components come with a few caveats that aren't immediately obvious if you're new to React.
318+
Higher-order components có một số lưu ý không rõ ràng nếu bạn là người mới học React.
320319

321320
### Đừng dùng HOC bên trong hàm render {#dont-use-hocs-inside-the-render-method}
322321

0 commit comments

Comments
 (0)