You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/higher-order-components.md
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -289,16 +289,15 @@ const enhance = compose(
289
289
constEnhancedComponent=enhance(WrappedComponent)
290
290
```
291
291
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.)
293
293
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).
296
295
297
296
## 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}
298
297
299
298
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.
300
299
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)`:
302
301
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)`
303
302
304
303
```js
@@ -316,7 +315,7 @@ function getDisplayName(WrappedComponent) {
316
315
317
316
## Caveats {#caveats}
318
317
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.
320
319
321
320
### Đừng dùng HOC bên trong hàm render {#dont-use-hocs-inside-the-render-method}
0 commit comments